Uploading Files
| From: | P. Guethlein | Date: | Sun, 21 May 2006 08:52:00 +0000 |
| Subject: | Uploading Files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-236566@lists.php.net to get a copy of this message | ||
I'm at one of those frustration levels.... can't seem to get a script working that will post and upload a file to the server. I"m working with the below. Can you help?
<?php
$numoffile = 1;
$file_dir = "d:/upload/";
if ($_FILES['myfiles']) {
print_r ($_FILES);
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>";
echo '
<form enctype="multipart/form-data" action="__URL__" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="myfiles" type="file" />
<input type="submit" value="Send File" />
</form>';
?>