jayesch Posted September 22, 2008 Share Posted September 22, 2008 Hello, I see this weird problem with ftp_put. I have checked for all common sources of errors and find that none of them apply for my case. 1) I can do ftp_chdir() to destination directory with success 2) I have write access the the destination directory. 3) I can upload files to FTP server from windows command prompt or other FTP clients. 4) File source path has no spaces in it(C:\test.txt) Unfortunately I do not have access to FTP server logs. FTP server is hosted on a MAC machine with OS-X 10.0 Here is the code snippet = 1. 2. $ftp_user_name='user'; 3. $ftp_user_pass='password'; 4. $ftp_server='somehost'; 5. $destination_file='test.txt'; 6. $src_file='c:\test.txt'; 7. 8. $conn_id = ftp_connect($ftp_server); 9. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 10. if(!ftp_chdir($conn_id,'/Documents/MobileMedia/site/uploads/video/mpeg')) 11. { 12. echo "No read permission in the destination directory </br>"; 13. } 14. if(!ftp_put($conn_id, $destination_file, $src_file, FTP_BINARY)) 15. { 16. echo "Upload operation to FTP server failed </br>"; 17. } 18. ftp_close($conn_id); 19. Let me know if there is anything wrong or there exists any other source of error. Thanks Jayesh Sharma Quote Link to comment Share on other sites More sharing options...
corbin Posted September 22, 2008 Share Posted September 22, 2008 Try using a full path..... IE: if(!ftp_put($conn_id, '/Documents/MobileMedia/site/uploads/video/mpeg/' . $destination_file, $src_file, FTP_BINARY)) Quote Link to comment Share on other sites More sharing options...
jayesch Posted September 23, 2008 Author Share Posted September 23, 2008 It fails still. My code initially had complete path in the ftp_put(). So to narrow down the problem I did a ftp_chdir() as an additional step. Also I have made doubly sure that I do have write permissions to the destination directory. HOST:/Library/WebServer/Documents/MobileMedia/site/uploads/video USER$ ls -l total 0 drwxrwxrwx + 6 USER admin 204 Sep 21 22:49 mpeg Quote Link to comment 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.