note 23864 added to features.file-upload
| From: | danCabral at lycos dot com | Date: | Tue, 30 Jul 2002 14:15:56 +0000 |
| Subject: | note 23864 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33993@lists.php.net to get a copy of this message | ||
after many attempts, i found this script from a previous posting above. worked the first time
without a hitch. good luck!
<?php
// Complete working file upload example, Win2KPro, Apache 1.3x, PHP 4.x
// Set this line in php.ini
// upload_tmp_dir = /Library/WebServer/yourURL.com/upload_directory/
function handleupload() {
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$realname = $_FILES['userfile']['name'];
print "<b>$realname</b> was uploaded successfuly to the upload directory";
print "";
copy($_FILES['userfile']['tmp_name'],
"/Library/WebServer/yourURL.com/upload_directory/".$realname);
} else {
echo "Possible file upload attack: filename
".$_FILES['userfile']['name'].".";
}
}
?>
<html><body>
<?php
if ($act == "upload") {
handleupload();
}
?>
<form ENCTYPE="multipart/form-data" method="POST"
action="ultest.php?act=upload">
File:<INPUT TYPE="FILE" NAME="userfile" SIZE="35">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="submit" value="Upload" name="B1">
Please click only <b>once</b> and wait for confirmation
</form>
<a href=ultest.php>clear form</a>
</body></html>
--
http://www.php.net/manual/en/features.file-upload.php
http://master.php.net/manage/user-notes.php?action=edit+23864
http://master.php.net/manage/user-notes.php?action=delete+23864
http://master.php.net/manage/user-notes.php?action=reject+23864