Answer the question
In order to leave comments, you need to log in
Why is sometimes the picture that comes through curl not complete?
request
$file = new \CURLFile($dir, 'image/jpg', $name);
// dd($file, $target_url);
set_time_limit(0);
$printname = 'print_'.$name;
$handle = fopen($printname,'w+');
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'file' => $file
]);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
// curl_setopt($ch,CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_FILE, $handle);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$raw=curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if($status === 200)
{
fwrite($handle, $raw);
fclose($handle);
}
else
{
fclose($handle);
dd('Err', $status);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question