0

I'm trying to upload a set of 3 files simultaneously to a LAMP server using the command line version of curl on Windows. The following command (referenced here) works perfectly on the linux version but doesn't send any files on when I try it on Windows port:

curl.exe -F file[][email protected] -F file[][email protected] -F file[]=3.mp4 https://www.blah.com/upload.php

upload.php accepts and processes the files:

if (!empty($_FILES)) {
        $total = count($_FILES['file']['tmp_name']);
        for ($i = 0; $i < $total; $i++) {
               //process files
        }
 }

Any idea what I'm doing wrong?

3
  • what was upload.php do? Commented Dec 23, 2016 at 4:24
  • accepts and processes the files. I'll add a piece of the code. Commented Dec 23, 2016 at 4:26
  • the PHP file works with multifile uploads. from linux curl, but only w/ a single file at a time with Windows curl. Commented Dec 23, 2016 at 4:29

1 Answer 1

0

If anyone else has trouble with this, I was able to get this to work by with following command:

curl.exe -F [email protected] -F [email protected] -F file3=3.mp4 https://www.blah.com/upload.php

Then with php I iterated through the files like so:

if (!empty($_FILES)) {
        foreach($_FILES as $file){
            $tempFile = $file['tmp_name'];
            $name       = $file['name'];
            //do something...
        }
}
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.