ntesla123 Posted March 13, 2011 Share Posted March 13, 2011 I have made this script to upload to an ftp server. How do I get the script to try to restart the upload if it fails? (if if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) returns false) <?php $file = 'file.wmv'; $remote_file = 'file.wmv'; // set up basic connection $conn_id = ftp_connect('ftp.eu.filesonic.com'); $ftp_user_name='username'; $ftp_user_pass='password'; // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // close the connection ftp_close($conn_id); ?> Quote Link to comment https://forums.phpfreaks.com/topic/230486-ftp-upload/ Share on other sites More sharing options...
redarrow Posted March 13, 2011 Share Posted March 13, 2011 looking at your code, I see that it the same as php.net. If you got permission to send a file or use ftp it will happen else not. A ftp problam is usally the password or members name . If you want to advance the code, maybe you need to add some ajax. you code looks ok , does it work. Your last else commnd stops un reg users uploding. like below. from php.net <?php $file = 'somefile.txt'; $remote_file = 'readme.txt'; // 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); // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } // close the connection ftp_close($conn_id); ?> Quote Link to comment https://forums.phpfreaks.com/topic/230486-ftp-upload/#findComment-1186896 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.