I need to limit the size of the file to be downloaded and tried using CURLOPT_PROGRESSFUNCTION
option with a callback to check on the size of the download and stop when it goes beyond 1kb this way:
$progress_handler = function( $download_size, $downloaded, $upload_size, $uploaded ) {
return ( $downloaded > 1024 ) ? 1 : 0;
}
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $progress_handler);
I tested this on few sites with download size in ~100kb but doesn't seem to stop at 1kb. Are there any other ways to apply the limit?
Thanks!