File upload problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

File upload problem

Post 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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

<input type="hidden" name="MAX_FILE_SIZE" value="1000">

1000 bytes is pretty small don't you think?
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

Post by sinewave »

thats not the problem obviously
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

Post by sinewave »

oh wow. you're right
i thought i had to actually check something AGAINST the file size.
thanks a ton.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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.
Post Reply