如何通过CURL PHP发送文件

时间:2019-07-09 09:54:14

标签: php curl

我正在尝试通过API curl将文件发布到另一个网站,但我一直收到“未收到文件数据-错误” 我尝试以多种方式添加文件路径,但始终收到相同的错误。 任何对此的见解将不胜感激

编辑*我在堆栈上尝试了其他可能的解决方案,但也无法使用

#这是我的卷曲请求     $ ch = curl_init();     curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_URL, 'http://upload.issuu.com/1_0');
 $curlfile = new CURLFile($filename,'/uploaded/',$filename);
//Create a POST array with the file in it
$postData = array(
    'apiKey' => 'xxx',
    'action' => 'issuu.document.upload',
    'file' => $curlfile,
    'title' => $title,
    'name' => $filename,
    'description' => $description,
    'category' => $category,
    'type' => $type,
    'commentsAllowed' => 'true',
    'infoLink   ' => $info_link ,
    'language' => 'en',
    'signature' => $sig,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

// Execute the request
$response = curl_exec($ch);
echo json_encode($response);
//echo '@/uploaded/'.$newFilePath;
echo realpath($newFilePath);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch);

0 个答案:

没有答案