Code: Select all
<?php
$fp = fopen($path, 'r');
$data = fread($fp, filesize($path));
fclose($fp);
$nf = fopen('images/' . basename($path), 'w');
fputs($nf, $data);
fclose($nf);
?>Moderator: General Moderators
Code: Select all
<?php
$fp = fopen($path, 'r');
$data = fread($fp, filesize($path));
fclose($fp);
$nf = fopen('images/' . basename($path), 'w');
fputs($nf, $data);
fclose($nf);
?>Code: Select all
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="max_file_size" value="2000000">
<tr>
<td><b>file upload</b></td>
<td></td>
</tr>
<tr>
<td>file: </td>
<td><input type="File" name="userfile" size="30" maxlength="255">
</td>
</tr>
<tr>
<td>target filename: </td>
<td><input type="Text" name="newname" size="30" maxlength="^255">
</td>
</tr>
<tr>
<tr>
<td>upload diretory: </td>
<td>c:\apache\upload\</td>
</tr>
<td colspan="2" align="CENTER">
<INPUT TYPE="submit" VALUE="upload">
</td>
</tr>
</form>Code: Select all
<?php
function do_upload( $filename , $newname )
{
$file = basename( $filename );
$tmp_upload_path = "/tmp/";
$new_file_name = "directory/".$newname; // Relative to www.your.com/
if ( !copy( $tmp_upload_path.$file, $new_file_name ) ) echo "failed to copy file<br>\n";
return;
}
?>
<html>
<head>
<title>uploading</title>
</head>
<body text="#000000">
<?php
do_upload( $userfile , $newname );
?>
<table>
<tr>
<td><b>upload report</b></td><td></td>
</tr>
<tr>
<td>upload tmp file:</td><td><?php echo $userfile; ?></td>
</tr>
<tr>
<td>file name:</td><td><?php echo $userfile_name; ?></td>
</tr>
<tr>
<td>target file name:</td><td><?php echo $newname; ?></td>
</tr>
<tr>
<td>file size:</td><td><?php echo $userfile_size; ?></td>
</tr>
<tr>
<td>file type:</td><td><?php echo $userfile_type; ?></td>
</tr>
</table>
</body>
</html>