使用php的FTP上传器 [英] FTP Uploader using php
问题描述
我正在使用jquery和php进行ftp图像上传,我正在使用ajax发送数据。
错误:
$ b我有以下代码,但无法使用,我收到以下错误消息。 $ b
警告:ftp_put()[function.ftp-put]:httpdocs / user_images /:不是/var/www/vhosts/kbba.biz/httpdocs/admin/php/upload.php在线的常规文件21
这是tmp_name: / tmp / phpQbG3el
代码:
$ 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);
您需要将文件名添加到远程路径像这样:
ftp_put($ conn_id,httpdocs / user_images /。$ _FILES ['fileToUpload'] ['name' ],$ _FILES ['fileToUpload'] ['tmp_name'],FTP_BINARY);
如果我上传myfile.txt,结果会是这样。
ftp_put($ conn_id,httpdocs / user_images / myfile.txt,/ tmp / phpQbG3el,FTP_BINARY);
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);
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);
这篇关于使用php的FTP上传器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!