madspof Posted October 10, 2007 Share Posted October 10, 2007 I need a script which can upload a file to a ftp server that requires a password. does anyone have a quick solution thnks madspof. Link to comment https://forums.phpfreaks.com/topic/72671-how-to-upload-a-file-to-a-ftp-server/ Share on other sites More sharing options...
madspof Posted October 10, 2007 Author Share Posted October 10, 2007 okay well i have made this script off the php.net site and all i need now is to figure out how to get the users file to the ftp server not the one on my server. i was thinking i might need to upload their file to mine then from there to the ftp server any way here the code $file = 'somefile.txt'; $fp = fopen($file, 'r'); // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); $response = ftp_chdir($conn_id, "www"); // try to upload $file if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) { echo "Successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // close the connection and the file handler ftp_close($conn_id); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/72671-how-to-upload-a-file-to-a-ftp-server/#findComment-366424 Share on other sites More sharing options...
redbrad0 Posted October 10, 2007 Share Posted October 10, 2007 PHP is a server based script, so with PHP there is not a way for you to upload files to a FTP server without first saving them to your local server. Link to comment https://forums.phpfreaks.com/topic/72671-how-to-upload-a-file-to-a-ftp-server/#findComment-366429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.