Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:41:52+00:00 2026-06-15T13:41:52+00:00

I am trying to transfer two files via PHP using cURL. I know the

  • 0

I am trying to transfer two files via PHP using cURL. I know the methodology via the command line would be

curl -T "{file1,file2,..filex}" ftp://ftp.example.com/ -u username:password

And within php you can upload 1 file via the following code

$ch = curl_init();
$localfile = "somefile";
$username = "Someusername@someserver.com";
$password = "somerandomhash";
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, "ftp://ftp.domain.com/");
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);

But how would I do multiple files using the above methodology?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:41:54+00:00Added an answer on June 15, 2026 at 1:41 pm

    If you can use the same credentials to connect to FTP in parallel, you could try to do that with minimum changes via curl_multi_* with the code like this:

    $chs = array();
    $cmh = curl_multi_init();
    for ($i = 0; $i < $filesCount; $i++)
    {
        $chs[$i] = curl_init();
        // set curl properties
        curl_multi_add_handle($cmh, $chs[$i]);
    }
    
    $running=null;
    do {
        curl_multi_exec($cmh, $running);
    } while ($running > 0);
    
    for ($i = 0; $i < $filesCount; $i++)
    {
        $content = curl_multi_getcontent($chs[$t]);
        // parse reply
        curl_multi_remove_handle($cmh, $chs[$t]);
        curl_close($chs[$t]);
    }
    curl_multi_close($cmh);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use scp to transfer files between two Macs (OS 10.6.8).
I'm trying to transfer Emails from Outlook to an Eclipse RCP application via drag
What I'm trying to accomplish: I have two base files on my server that
I have two databases that I'm trying to transfer data between. I'm working on
I'm trying to send a multipart/alternative MIME e-mail via PHP script ... all works
I am trying to transfer a large (~3GB) file between two unix machines. I
I'm trying to perform two tasks (separated into 2 kernels) on the GPU using
Trying to have a PHP script send an email that contains two images that
I'm trying to implement a basic file transfer protocol, using UDP. I'm using Beej's
I am trying to write a dynamic form using PHP. I'd like to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.