Page 1 of 1

File upload problem

Posted: Fri Oct 25, 2002 8:04 pm
by sinewave
I'm having a small file uploading problem...
i keep getting the error:

Warning: Unable to open 'none' for reading: No such file or directory in /home/www/html/upload.php on line 11

Here's the HTML

Code: Select all

<form enctype="multipart/form-data" action="<?PHP $PHP_SELF ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file: <input name="userfile" type="file">
<input name="submit" type="submit" value="Send File">
</form>
And the PHP:

Code: Select all

<?php
if(isset($HTTP_POST_VARSї"submit"])) 
{ 

$target = "/home/www/html/uploads"; 
if (is_dir($target) AND is_writable($target)) 
{
   $filename = $HTTP_POST_FILESї'userfile']ї'name'];
   copy($HTTP_POST_FILESї'userfile']ї'tmp_name'], "$target/$filename");  
}
else
echo $target. ': invalid or write was denied';
} 
    
 ?>
if anyone knows....you'll make me happy

Posted: Fri Oct 25, 2002 9:30 pm
by hob_goblin
<input type="hidden" name="MAX_FILE_SIZE" value="1000">

1000 bytes is pretty small don't you think?

Posted: Fri Oct 25, 2002 9:48 pm
by sinewave
thats not the problem obviously

Posted: Fri Oct 25, 2002 10:10 pm
by hob_goblin
Well, have you tried setting it higher? Internet Explorer, or whatever browser you might be using, probably won't send the file if it is over the max_file_size, so the $HTTP_POST_FILES array would be empty.

you need to be more open-minded obviously

Posted: Fri Oct 25, 2002 10:24 pm
by sinewave
oh wow. you're right
i thought i had to actually check something AGAINST the file size.
thanks a ton.

Posted: Fri Oct 25, 2002 10:44 pm
by hob_goblin
If you're trying to limit the filesize, I would definantly check it in the php script, cause someone can just send a form they made theirself.