...

View Full Version : file upload problem



JAP43
11-06-2006, 09:29 AM
i tried a code for file upload(http://php.snippetdb.com/view.php?ID=69) but i didnt get it to work. here is my code in filesend.php:

<?php
// basic php file upload example
// http://php.snippetdb.com

if ($_POST['upload']){ //process uploaded file
$uploadDir = '/uploads/'; //file upload path
$uploadFile = $uploadDir . $_FILES['uploadfile']['name'];
echo "<pre>";
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadFile) )
{
echo "File is valid, and was successfully uploaded. ";
echo "Here's some more debugging info:\n";
}
else
{
echo "ERROR! Here's some debugging info:\n";
echo "remember to check valid path, max filesize\n";
}
var_dump($_FILES);
echo "</pre>";

} else { //display upload form
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1024000">
<br>
<input name="uploadfile" type="file">
<br>
<input name= "upload" type="submit" value="Upload File">
</form>
<?php
}
?>

i made the directory named uploads and i chmod 777 both the file and the directory. It gives me a error message:Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 26946 is not allowed to access / owned by uid 0 in /home/865095/public_html/filesend.php on line 9

ERROR! Here's some debugging info:
remember to check valid path, max filesize
array(1) {
["uploadfile"]=>
array(5) {
["name"]=>
string(9) "test.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(14) "/tmp/phpnbw4Dy"
["error"]=>
int(0)
["size"]=>
int(5)
}
}

What's wrong with it?Any ideas?

MRMAN
11-06-2006, 12:16 PM
In php when SAFE MODE is on when you upload a file PHP checks to see if the owner of the upload file is the same as the php file. If they are the same then everything is ok if the owners are different then itt will not upload.

"The script whose uid is 26946 is not allowed to access / owned by uid 0 in /home/865095/public_html/filesend.php"

as you can see you are trying to upload a file whos owner is 26946 with a file whos owner is 0. I think the only way to make it work is to set SAFE MODE to false



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum