How I got PHP under Windows to upload a file
| From: | Adrian Teasdale | Date: | Fri, 23 Jun 2000 23:42:32 +0000 |
| Subject: | How I got PHP under Windows to upload a file | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-630@lists.php.net to get a copy of this message | ||
Hi all - just thought I'd put something back into the community :)
I had a question a week or so ago about file uploads under Windows. I have
managed to solve this and I thought I would share this as the question came
up yesterday again....
Within PHP.ini I put the file upload file settings to:
upload_tmp_dir = /Windows/Temp/
and then I tried this test code:
<?
// check for file upload
if(isset($uploadedfile))
{
// copy the uploaded file to a different location - in this instance
// to the c: drive.
copy ($uploadedfile, "c:\\$uploadedfile_name");
// just echo some variables back to the screen
echo "local file: $uploadedfile<br>";
echo "Name: $uploadedfile_name<br>";
echo "size: $uploadedfile_size<br>";
echo "Type: $uploadedfile_type<br>";
}
?>
<form action ="<?php echo $PHP_SELF ?>" method="post"
ENCTYPE="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input name="uploadedfile" type="file">
<input type="submit" value="upload">
</form>
</body>
</html>
Make sure that you copy the file from the temp directory to wherever you
want it to be before it is deleted!. I did this with:
copy ($uploadedfile, "c:\\$uploadedfile_name");
I hope that this helps someone out - this is a problem which has been
bugging me now for around a year!!!!
All the best to everyone and have a good weekend
Ade