FTP functions in PHP

software development

#1

Hello,

I need to upload a list of files from a specified user directory.
I’ve had success uploading single files using a form, however, the following script returns an error at the ftp_put function. The chmod, ftp login and chdir functions work great - ftp_pwd does return the given directory.

Any suggestions?
Thanks,
Kevin

<?php // temporarily make the photos directory writeable by all if (chmod ("test/photos", 0777)) { echo "chmod succeeded" . " "; } else { echo "chmod failed" . " "; } $file = "c:\\test.txt"; $remote_file = "test.txt"; // set up basic connection $conn_id = ftp_connect($my_ftp_server); // login with username and password $login_result = ftp_login($conn_id, $my_userid, $my_password); echo "login status: " . $login_result . " "; // change directory ftp_chdir($conn_id, 'test'); ftp_chdir($conn_id, 'photos'); // print current directory echo ftp_pwd($conn_id) . " "; // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem uploading $file "; } // close the connection ftp_close($conn_id); if (chmod ("test/photos", 0744)) { echo "chmod succeeded" . " "; } else { echo "chmod failed" . " "; } ?>