在托管服务器中保存文件的php代码

在托管服务器中保存文件的php代码,php,Php,当我使用下面的代码保存图像时,它保存得非常完美 这是剧本的一部分,我唯一面临的问题是 我认为这是由于代理使用。。 bt我必须在这个脚本中使用代理,所以不能删除它 bt plz需要一个正确的答案 这里没有脚本的代理部分 if(preg_match_all('/unsanswerit.php(.*?)"/i',$html, $matches)) { $img="".$url."/unsanswerit.php".$matches[1][3].""; curl_setopt($ch,

当我使用下面的代码保存图像时,它保存得非常完美

这是剧本的一部分,我唯一面临的问题是 我认为这是由于代理使用。。 bt我必须在这个脚本中使用代理,所以不能删除它 bt plz需要一个正确的答案

这里没有脚本的代理部分

if(preg_match_all('/unsanswerit.php(.*?)"/i',$html, $matches))
{
    $img="".$url."/unsanswerit.php".$matches[1][3]."";
    curl_setopt($ch, CURLOPT_URL, $img);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

    $abc=curl_exec($ch);
    $name=rand(0, 999999);
    $path='img/'.$name.'.png';

    $fh = fopen($path, "x");
    fwrite($fh, $abc);
    fclose($fh);

    $st=file_get_contents($path);

    $image=imagecreatefromstring($st);
    $anf= img2txt($image);
    imagedestroy($image);
}
下面是脚本的一部分,其中包含代理

if(preg_match_all('/unsanswerit.php(.*?)"/i',$html, $matches))
{
    $img="".$url."/unsanswerit.php".$matches[1][3]."";
    curl_setopt($ch, CURLOPT_URL, $img);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

    $abc=curl_exec($ch);
    $name=rand(0, 999999);
    $path='img/'.$name.'.png';

    $fh = fopen($path, "x");
    fwrite($fh, $abc);
    fclose($fh);

    $st=file_get_contents($path);

    $image=imagecreatefromstring($st);
    $anf= img2txt($image);
    imagedestroy($image);   
}

好了,伙计们,我找到了解决办法 它的标题问题
通过curl exe保存图像时,标题应为false

代理会出现什么错误?您可能需要提供该代理的用户名和密码