note 19003 added to features.file-upload
| From: | dspotts at mac dot com | Date: | Wed, 13 Feb 2002 08:28:29 +0000 |
| Subject: | note 19003 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26538@lists.php.net to get a copy of this message | ||
<?php
// Complete working file upload example, Win2KPro, Apache 1.3x, PHP 4.x
// Set this line in php.ini
// upload_tmp_dir = c:\inetpub\wwwroot\uploads
function handleupload() {
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$filename = $_FILES['userfile']['tmp_name'];
print "$filename was uploaded successfuly<br>";
$realname = $_FILES['userfile']['name'];
print "realname is $realname<br>";
print "copying file to uploads dir";
copy($_FILES['userfile']['tmp_name'],
"c:\\inetpub\\wwwroot\\uploads\\".$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"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="submit" value="Upload"
name="B1"><br><br>
Please click only <b>once</b> and wait for confirmation
</form>
<br><br>
<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+19003
http://master.php.net/manage/user-notes.php?action=delete+19003
http://master.php.net/manage/user-notes.php?action=reject+19003