phpfileformsftpuploading

How to upload a file using php to the parent directory


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?


Solution

  • The usual method is to call move_uploaded_file(), where you set the destination path to your liking. The file name in $_FILES['tmp_name'] normally points to a temporary folder and it's subject to be removed without prior notice.