Jump to content

[SOLVED] move_uploaded_file server issues?


eatadi

Recommended Posts

I am using this simple peice of code below to upload a file from an html form. The issue is that it works fine on a godaddy linux server, but I get there was an error uploading the file message when trying the same code on a Verio unix server. It's driving me NUTS! Any ideas? I looked over permissions a trillion times, is there anything I have to set in the php.ini file or any error handling i can add to get specific issue?

 

$target_path = "modelresumes/";

 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

    echo "The file ".  basename( $_FILES['uploadedfile']['name']).

    " has been uploaded";

} else{

 

    echo "There was an error uploading the file, please try again!";

}

 

thanks.

Link to comment
https://forums.phpfreaks.com/topic/173589-solved-move_uploaded_file-server-issues/
Share on other sites

Could be one of several possible problems. What do you get when you add the following code immediately after your first opening <?php tag -

 

ini_set("display_startup_errors", "1");
ini_set("display_errors", "1");
error_reporting(E_ALL);
echo "<pre>";
echo "POST:";
print_r($_POST);
echo "FILES:";
print_r($_FILES);
echo "</pre>";

Hi,

 

I get the following message.

 

POST:Array

(

    [MAX_FILE_SIZE] => 100000

)

FILES:Array

(

    [uploadedfile] => Array

        (

            [name] => FINAL-SEAN-KINGSTON-INVITE.jpg

            [type] =>

            [tmp_name] =>

            [error] => 6

            => 0

        )

 

)

There was an error uploading the file, please try again!

 

From what I read, error 6 means that the server is missing a temporary folder. I checked the server and on the root, tmp is on the server and I changed the permissions, but I still get the same error. Is there something in the php.ini file I need to change?

 

 

Check what a phpinfo(); statement shows for the upload_tmp_dir setting. It is probably set to some specific folder that does not exist. Either change it to point to a folder that does exist or create a folder that matches what it is set to. Stop and start your web server to get any change made to php.ini to take effect and use a phpinfo() statement to confirm that the setting was actually changed.

 

upload_tmp_dir string

The temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as. If not specified PHP will use the system's default.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.