Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-06-2006, 08:29 AM   PM User | #1
JAP43
New Coder

 
Join Date: Oct 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
JAP43 is an unknown quantity at this point
file upload problem

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:
Code:
<?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?
JAP43 is offline   Reply With Quote
Old 11-06-2006, 11:16 AM   PM User | #2
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
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
MRMAN is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:03 AM.


Advertisement
Log in to turn off these ads.