Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with PHP 4.1.1 on Win32 and file uploads 1

Status
Not open for further replies.

danielhozac

Programmer
Aug 21, 2001
2,058
SE
Is there a problem with file uploads in PHP 4.1.1 for Windows?
I tried this script (copied from php.net)
<?php
if (is_uploaded_file($_FILES['userfile']))
{
if (copy($_FILES['userfile']['tmp_name'], &quot;./uploads/&quot;))
echo &quot;Upload successful.&quot;;
}
?>
<form action=&quot;<?=$PHP_SELF?>&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
<input type=&quot;file&quot; name=&quot;userfile&quot; /><br />
<input type=&quot;submit&quot; value=&quot;send&quot;>
</form>
but it doesn't work.
What might be the problem? //Daniel
 
Are you getting any error messages, warnings or anything else?

Also, change
if (is_uploaded_file($_FILES['userfile']))
to be
if (is_uploaded_file($_FILES['userfile']['tmp_name']))

and
if (copy($_FILES['userfile']['tmp_name'], &quot;./uploads/&quot;))
to be
if (copy($_FILES['userfile']['tmp_name'], &quot;uploads/&quot;))

And yes, file uploads do work with windows.

I hope that helps you out. If not, let me know.
 
I know that file uploads work on windows, they worked before I updated PHP.
As of the code, it is, as I said, copied from PHP.net's own documentation for file uploads.
./uploads/ is the same as uploads/.
And no, I do not get any errors, warnings or other messages.
The problem is that is_uploaded_file($_FILES['userfile']) always returns false. //Daniel
 
I answered the question of whether there was a problem with file uploads in Windows that you asked in your original post.

$_FILES['userfile'] will return false becuase you have to test the actual uploaded filename by using $_FILES['userfile']['tmp_name'] as I stated in my reply.
 
Ok, that actually worked... I thought that the PHP documentation would be correct, sorry. //Daniel
 
Ok, that actually worked... I thought that the PHP documentation would be correct, sorry.

Thanks a lot. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top