Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php foreach中的curl上载文件更改我的post值_Php_Api_Curl_File Upload - Fatal编程技术网

Php foreach中的curl上载文件更改我的post值

Php foreach中的curl上载文件更改我的post值,php,api,curl,file-upload,Php,Api,Curl,File Upload,我有derectory和start scan目录,只获取jpg文件,并在start foreach之后放入数组 foreach(files as file) { $cfile = new CURLFile('HERE FULL PATH TO FILE', $mime, $file); $target_url = "https://xxxxx.com/api/handler.php"; $data = array('file' => $cfile, 'dir' =&

我有derectory和start scan目录,只获取jpg文件,并在start foreach之后放入数组

foreach(files as file) {
    $cfile = new CURLFile('HERE FULL PATH TO FILE', $mime, $file);
    $target_url = "https://xxxxx.com/api/handler.php";
    $data = array('file' => $cfile, 'dir' => 'Derectory where need upload file if not exist i create in handler.php for example /var/www/xxx/test/');
    $ch = curl_init($target_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
    $result = curl_exec($ch);
    if ($result) {
        curl_close($ch);
        // do something
    } else {
        curl_close($ch);
        // error
    }
}
当我上传1700张或更多图片时 卷曲开始换我的

$\u POST['dir']

例如,在1210 rd图像中,更改了我的

$\u POST['dir']

“/var/www/xxx/test/”

“/var/www/xxx/te/va/www/x”

像这样
谁知道在这种情况下会出现什么问题呢,谢谢。

那么,
handler.php
或您的
$files
源代码不是更相关吗?您知道,我们很感激将示例代码减少到必要的部分。但是这个curl_uu摘录似乎不是你问题的明显原因。在
handler.php
中,我把
$\u POST['dir']
放在.txt文件中,看看curl如何在发送之前更改我的
$\u POST['dir']
,一切都很好,我不知道为什么curl会更改我的
$\u POST['dir']
没有人知道您的
dir=
参数发生了什么,因为这是摘录未解释的部分。