473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

why can't upload file into ftp target directory with curl?

The file `d:/upload.sql` in my local pc can be uploaded into `my_ftp_ip/public_html/upload_ftp_put.sql` with code1.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     set_time_limit(0);
  3.     $host = 'xxxx';
  4.     $usr = 'yyyy';
  5.     $pwd = 'zzzz';
  6.     $src = 'd:/upload.sql';
  7.     $ftp_path = '/public_html/';
  8.     $des = 'upload_ftp_put.sql';
  9.     $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
  10.     ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
  11.     $upload = ftp_put($conn_id, $ftp_path.$des, $src, FTP_ASCII); 
  12.     print($upload);
  13. ?>
  14.  
Now i rewite it with curl into code2.

code2:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   set_time_limit(0);
  3.   $ch = curl_init();
  4.   $host = 'xxxx';
  5.   $usr = 'yyyy';
  6.   $pwd = 'zzzz';
  7.   $src = 'd:/upload.sql';
  8.   $ftp_path = '/public_html';
  9.   $dest = 'upload_curl.sql';
  10.   $fp = fopen($src, 'r');
  11.   curl_setopt($ch, CURLOPT_URL, 'ftp://user:pwd@host/'.$ftp_path .'/'. $dest);
  12.   curl_setopt($ch, CURLOPT_UPLOAD, 1);
  13.   curl_setopt($ch, CURLOPT_INFILE, $fp);
  14.   curl_setopt($ch, CURLOPT_INFILESIZE, filesize($src));
  15.   curl_exec ($ch);
  16.   $error_no = curl_errno($ch);
  17.   print($error_no);
  18.   curl_close ($ch);
  19. ?>
  20.  
The erroor info output is 6 .Why can't upload my local file into the ftp with curl?How to fix it?
Aug 31 '15 #1
0 1237

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Muppy | last post by:
I've created a page with a form to upload files: <h1>Upload di un file</h1> <form enctype="multipart/form-data" method="post" action="do_upload1.php"> <p><strong>File da trasferire:</strong><br>...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
4
by: Andy Gilman | last post by:
I want a method basically that tells me if a path is a file or directory, or any other possibilities. What do i need to do? I'm hoping I dont have to manually determine all these things with...
2
by: Trint Smith | last post by:
My calendar control erases my upload file control data... The control that allows you to select a file for upload???, well after I do that, I click on the calendar day and when the screen recovers...
1
by: John | last post by:
Dear, We have 2 IIS server on win2000. we use the web server for upload file from server1 IIS to server2 IIS. We can connect from IIS1 to IIS2 success but the file unable to upload with below...
4
by: finecur | last post by:
I can upload files with <form action=...> <input type=file...> </form> Suppose I do not want to refersh my page. Then how can I upload file without call the form's action or refresh my html...
2
by: suresh_nsnguys | last post by:
Hi, I am working in digital signage application where user can upload image,flash and movie files .and later thay can view the uploaded files in digital LCD screen. I am facing 1...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
2
by: Jeff Dege | last post by:
I have a VS2005 Web Site that's giving me some trouble. Our process model requires that all shipped applications be compiled on a dedicated compile box, straight from version control, without...
1
by: printline | last post by:
Hello all I have a php script that uploads a file from a form into a directory. The directory is automatically created through the script. But the upload file is not put in to the directory,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.