note 10781 added to Handling file uploads
| From: | inergy at netzero dot net | Date: | Mon, 22 Jan 2001 05:28:11 +0000 |
| Subject: | note 10781 added to Handling file uploads | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10058@lists.php.net to get a copy of this message | ||
error:
Warning: Unable to open 'C:\test\test.exe' for reading: No such file or directory in
/home/admin/index.php3 on line 19
line 19:
copy($userfile, $filepath);
index.php:
<?php
if (!$upload) {
print(
"<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"index.php3\"
METHOD=POST>".
"<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\"
value=\"2000000\">".
"<INPUT TYPE=\"hidden\" name=\"acctid\"
value=\"upload\">".
"<INPUT TYPE=\"hidden\" name=\"pgid\"
value=\"members\">".
"File:<br><input type=\"file\"
name=\"userfile\"><br>".
"<input type=\"submit\" name=\"upload\"
value=\"Send\">"
);
} else {
if ($userfile == "none") {
print ("No file was uploaded, or file was of 0 length.");
} else {
$userfile=htmlentities(stripslashes("$userfile"));
$file=basename($userfile_name);
$filepath="content/upload/files/";
$counter=0;
copy($userfile, $filepath);
print(
"<b>File Uploaded!</b><br>\n".
"<b>File Name:</b> $file<br>\n".
"<b>File Size:</b> $userfile_size<br>\n".
"<b>File Type:</b> $userfile_type<br>\n"
);
$image_types=array(
"image/gif" => true,
"image/jpeg" => true,
"image/pjpeg" => true
);
if ($image_types[$userfile_type]) {
print(
"<b>Image Preview:</b><br>\n".
"<img src=\"".$filepath.$file."\">\n"
);
}
}
}
?>
</FORM>
http://www.php.net/manual/en/features.file-upload.php