title: How to upload file by PHP cURL using ftp connection?
body: <p>I am using this script to upload myfile by curl function and ftp connection.</p>
  
  <p>In local it works fine but in my server file is appeared uploaded but it have zero file size.</p>
  
  <p>what is wrong? Thank You.</p>
  
  <pre><code>$ch = curl_init();
  $localfile = (dirname(__FILE__).'/asset/myfile.zip');
  $fp = fopen($localfile, 'r');
  curl_setopt($ch, CURLOPT_URL, "ftp://$user_name:$user_pass@$server/".'myfile.zip');
  curl_setopt($ch, CURLOPT_UPLOAD, 1);
  curl_setopt($ch, CURLOPT_INFILE, $fp);
  curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
  curl_exec ($ch);
  curl_close ($ch);
  </code></pre>
  
  <p>and also how can I upload multiple files in this script like:</p>
  
  <pre><code>$localfile1 = (dirname(__FILE__).'/asset/myfile1.zip');
  $localfile2 = (dirname(__FILE__).'/asset/myfile2.zip');
  $localfile3 = (dirname(__FILE__).'/asset/myfile3.zip');
  </code></pre>