0

i am trying to upload file using curl but if two file are trying to upload then its upload same file twise .

ch_thumb = curl_init();
curl_setopt($ch_thumb, CURLOPT_URL, $url);
curl_setopt($ch_thumb, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch_thumb, CURLOPT_SSL_VERIFYPEER, false);
$fname = $file_name;
$data->$fname = new CURLFile ('images/'.$fname);
curl_setopt($ch_thumb, CURLOPT_SAFE_UPLOAD, true);
curl_setopt($ch_thumb, CURLOPT_POSTFIELDS, $data);
$resp = curl_exec($ch_thumb);   
clearstatcache();                       
curl_close($ch_thumb);

please provide solution for that how can i solve.

3
  • This SO Link has a solution for multiple file upload using cURL. Commented May 4, 2017 at 10:41
  • i am able to upload file but same file was upload i send different file name but get previous file on both response Commented May 4, 2017 at 12:19
  • Possible duplicate of Uploading multiple files in PHP using HTML Form or cURL Commented May 4, 2017 at 12:59

1 Answer 1

0

Just make a function and add this function into foreach loop like below u get it.

<?php
    foreach($url)
    {
    upload_file($url);
    }    
    function upload_file($url)
    {
      // Add your file upload code in this function 
    }
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.