upload problems
Posted: Thu Mar 11, 2004 5:47 am
I am having some problems with an upload script.
When testing on my home machine the code works intermittently.
sometimes it will say that the file is valid and uploaded. the next time I try I am told :
Possible file upload attack! Here's some debugging info:
Array
(
[userfile] => Array
(
[name] => boo.doc
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)
)
The file exists as I have used a browse button to find it.
Below is my upload code
<?php
$uploaddir = 'gifs/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
// print "Here's some more debugging info:\n";
// print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>
when i test on my 'server' i get the following message:
Warning: move_uploaded_file(gifs/house.gif): failed to open stream: Permission denied in /home/virtual/site8/fst/var/www/html/dbshoes/savefile.php on line 53
Can anyone tell me what I am doing wrong please
Is this something to do with the code or do I need to get something done to the folder?
Any help appreciated
When testing on my home machine the code works intermittently.
sometimes it will say that the file is valid and uploaded. the next time I try I am told :
Possible file upload attack! Here's some debugging info:
Array
(
[userfile] => Array
(
[name] => boo.doc
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)
)
The file exists as I have used a browse button to find it.
Below is my upload code
<?php
$uploaddir = 'gifs/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
// print "Here's some more debugging info:\n";
// print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
?>
when i test on my 'server' i get the following message:
Warning: move_uploaded_file(gifs/house.gif): failed to open stream: Permission denied in /home/virtual/site8/fst/var/www/html/dbshoes/savefile.php on line 53
Can anyone tell me what I am doing wrong please
Is this something to do with the code or do I need to get something done to the folder?
Any help appreciated