When this is on my server, how would I write the path ($source_file) to a file on my local computer? And how can I put the file inside my created folder? <?php // set up basic connection $conn_id = ftp_connect("ftp.mysite.com"); // login with username and password $login_result = ftp_login($conn_id, "user", "pass"); // check connection if ((!$conn_id) || (!$login_result)) { echo "Failed!"; exit; } else { echo "Connected"; } $source_file = 'path to my file on local computer'; $destination_file = 'destinationName.avi'; // Destination directory $dir = $_SERVER['DOCUMENT_ROOT'].'/uploadedFiles/'; // Make directory $newFolder = mkdir($dir.'myFolder',0777); // upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded"; } // close the FTP stream ftp_close($conn_id); ?> PHP:
Uhm. You can't, if I understand you correctly. PHP can't automatically access files on your local computer (thank heavens). You can, however, make a form where you have a file browser/input and you select the file - the rest of the task can be automated as you want it to be. Google for "upload files with php ftp" or something similar.
Ok, I was just wondering how the path will look like when it's sent to the PHP script. will it be "C:\user\myfile.jpg" or what will the path be?
It is completely irrelevant? It's not sent anything to the PHP-script - you chose a location on your local computer, and the file saves itself there - it's not being sent any information as to where you save it to the PHP-file.