FTP Uploader using php

≯℡__Kan透↙ 提交于 2019-12-22 11:35:36

问题


I am making a ftp image upload using jquery and php i am using ajax to send the data. I have the following code but its not working i am getting the following error.

Error:

Warning: ftp_put() [function.ftp-put]: httpdocs/user_images/: Not a regular file in /var/www/vhosts/kbba.biz/httpdocs/admin/php/upload.php on line 21

This is the tmp_name: /tmp/phpQbG3el

Code:

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

ftp_put($conn_id, "httpdocs/user_images/", $_FILES['fileToUpload']['tmp_name'], FTP_BINARY); 

print_r($_FILES['fileToUpload']['tmp_name']);

ftp_close($conn_id);

回答1:


You need to add a file name to the remote path like so:

ftp_put($conn_id, "httpdocs/user_images/" . $_FILES['fileToUpload']['name'], $_FILES['fileToUpload']['tmp_name'], FTP_BINARY);

This would be the outcome if I upload myfile.txt

ftp_put($conn_id, "httpdocs/user_images/myfile.txt","/tmp/phpQbG3el", FTP_BINARY);


来源:https://stackoverflow.com/questions/4725215/ftp-uploader-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!