Multiple file uploads with cURL

删除回忆录丶 提交于 2019-12-01 19:20:13

here is your error in the curl call...

var_dump($post)

you are clobbering the array entries of your $post array since the key strings are identical...

make this change

$post = array(
    'upload[0]' => '@' . $tmp_uploads . $filename,
    'upload[1]' => '@' . $tmp_uploads . $thumbname,
    'salt' => 'q8;EmT(Vx*Aa`fkHX:up^WD^^b#<Lm:Q'
);

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!