0

curl 似乎只上传了 10 个字节。$url 正确,$file 路径也正确,文件存在!

我有这个代码:

curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);

    $post   = array(
        "id" => $id,
        "api_key" => $api_key,
        "file" => "@".$_SERVER['DOCUMENT_ROOT']."/".$file
        );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $response = curl_exec($ch);
4

1 回答 1

0

如果 url 正确,则代码对我来说很好。您是否检查过 $file_path 是否有效并具有读取权限?

于 2013-08-24T05:39:13.600 回答