Michael St Clair
Michael St Clair

Reputation: 6615

What Do I Need To Set Directory To

I get this error when my script is trying to put an image in a folder. The photo should be going in techportal/images/1/image.jpg. What do I need to define my directory as to make this work right?

move_uploaded_file(): Unable to move '/var/tmp/phpsYW3wW' to '../images/1/profile.jpg' in /home4/saintfiv/public_html/pianotunerpros/techportal/index.php on line 26

Upvotes: 0

Views: 55

Answers (2)

Ankur Saxena
Ankur Saxena

Reputation: 639

few day back i'm facing same problem i think this error occurs due incorrect path provide by you.you provide path like "../images/1/profile.jpg" is incorrect way you use like "images/1/profile.jpg".use dirname(__FILE__) give you present location of file and you have provide path from location to where you want to upload. like:-

"C:\wamp\www\familypark\administer" //location where my upload.php file exits
"C:\wamp\www\familypark\administer\assets\upload\park_images"//location from root where i want to upload my picture
so i used like this and hence it work fine
$path='assets/upload/park_logo/';
                                move_uploaded_file($_FILES['logo_upload']['tmp_name'],$path.$_FILES['logo_upload']['name']); 

Upvotes: 0

zaf
zaf

Reputation: 23244

The error reports the script path:

/home4/saintfiv/public_html/pianotunerpros/techportal/index.php

In a simple setup, a "../images/1/profile.jpg" path does not point to the location you want.

Try using "images/1/profile.jpg" and make sure the directory is created and writable.

Also, to make certain which directory you are in try playing with the getcwd() and chdir() functions, they can help you out a lot in debugging:

http://php.net/manual/en/function.getcwd.php

http://php.net/manual/en/function.chdir.php

Upvotes: 3

Related Questions