View Full Version : file upload problem

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:

// 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";
echo "ERROR! Here's some debugging info:\n";
echo "remember to check valid path, max filesize\n";
echo "</pre>";

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

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) {
array(5) {
string(9) "test.txt"
string(10) "text/plain"
string(14) "/tmp/phpnbw4Dy"

What's wrong with it?Any ideas?

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