Multiple file uploads with cURL

前端 未结 2 898
死守一世寂寞
死守一世寂寞 2021-01-18 23:09

I\'m using cURL to transfer image files from one server to another using PHP. This is my cURL code:

// Transfer the original image and thumbnail to our stora         


        
2条回答
  •  Happy的楠姐
    2021-01-19 00:07

    The code itself looks ok, but I don't know about your move() target directory. You're using the raw filename as provided by the client (which is your curl script). You're using the original uploaded filename (as specified in your curl script) as the target of the move, with no overwrite checking and no path data. If the two uploaded files have the same filename, you'll overwrite the first processed image with whichever one got processed second by PHP.

    Try putting some debugging around the move() command:

    if (!move_uploaded_file($_FILES['upload']['tmp_name'][$key], $_FILES['upload']['name'][$key])) {
       echo "Unable to move $key/";
       echo $_FILES['upload']['tmp_name'][$key];
       echo ' to ';
       echo $_FILES['upload']['name'][$key];
    }
    

    (I split the echo onto multiple lines for legibility).

提交回复
热议问题