How to upload a file using php to the parent directory

user571532 picture user571532 · Jan 11, 2011 · Viewed 9.2k times · Source

Hopefully easy question, I have a desktop application that allows the user to upload a file to a server using a form, the form sends the data to a protected file on the site like this. Site_root/protected_folder/myfile.php . If you use php file upload commands normally you'd be operating in the 'protected_folder' directory, which I don't want.

I want to add stuff to the images file on the root directory like this Site_root/images/ , how would you go about doing this without going the ftp root?

Answer

Prisoner picture Prisoner · Jan 11, 2011

You can either use an absolute path like /path/to/images/ or use a relative path like ../images/

Assuming you're using move_uploaded_file the second paramater takes the directory that you wish to upload to. Perhaps showing you code may help if this post doesn't.