Create a small file upload form:
Please note that upl.php, is the name of the file where data is transmitted, which should contain a function of processing and uploading the file. Also, in describing the form, you must specify a string
which allows you to upload any data. If you have not downloaded the file on the FTP, first check that you have added this feature.
Code the file upl.php:
$ login and $ pass - username and password of your FTP account
$ host - the name of your FTP (for example, ftp.microsoft.com)
$ path - the inner path to the folder where you want to download the file (permissions for this folder must be on record).
For example / alex / download / upload /.
Determine the name of the temporary file to upload. It is necessary to explain the principle of the file download.
Once you have clicked on the "Import" button, the file was placed in a temporary directory on your server (usually a folder tmp).
Only then we can work with this file and send it to the right place.
Usually, the contents of the folder tmp is destroyed automatically, but that would be safe at the end of all operations necessary to delete the file itself
Now you need to connect to FTP:
Immediately check to see if a connection is absent ($ connect = false) or has an invalid login data and / or password ($ result = false) then stop execution of the function.
Further, by using the ftp_chdir go into the folder $ path and load the file by using ftp_put:
The file is loaded, now need to disconnect from the FTP and delete the temporary file:
Now feasible function call:
If the user selects a file ($ filename is not empty), then load the file on the ftp.