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
sinewave
Forum Commoner
Posts: 41 Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada
Post
by sinewave » Fri Oct 25, 2002 8:04 pm
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
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Fri Oct 25, 2002 9:30 pm
<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 » Fri Oct 25, 2002 9:48 pm
thats not the problem obviously
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Fri Oct 25, 2002 10:10 pm
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 » Fri Oct 25, 2002 10:24 pm
oh wow. you're right
i thought i had to actually check something AGAINST the file size.
thanks a ton.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Fri Oct 25, 2002 10:44 pm
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.