John Davidson

php - IDM (Internet Download Manager) takes x2 time to download my ZIP file

0 comments
Message:


I ZIP all my reports into a single ZIP file. When I turn off IDM, the download process tooks 20 seconds. But when enable IDM, it tooks 20 seconds to show the IDM download dialog, then after I click OK, it tooks another 20 seconds.


Can I do something bout this at my PHP code so that IDM user wont suffer? Or any explanation?


This is how I create Zip file in PHP:


$zip = new ZipArchive();
$filename = "Test.zip";
if($zip->open($filename, ZipArchive::CREATE)!==TRUE) die("cannot open <$filename>\n");

foreach([1,2,3,4,5] as $id) {
$path = dirname($_SERVER['HTTP_REFERER']) . '/myreport.php';
$ch = curl_init($path);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['id' => $id]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
$get_file = curl_exec($ch);
curl_close($ch);
if($get_file === false) echo 'CURL ERROR: '.curl_error($ch);

$zip->addFromString("Report $id.pdf", $get_file);
}

$zip->close();
header('Content-disposition: attachment; filename='.$filename);
header('Content-type: application/zip');
ob_clean();
readfile($filename);
unlink($filename);

die;


My Answer:
"reports.zip";_$zip->open($filename, ZipArchive::CREATE);_foreach ($reports as $report) {_ $zip->addFile($report);_}_$zip->close();_header("Content-Type: application/zip");_header("Content-Disposition: attachment; filename=" . $filename);_readfile($filename);_

The issue you are experiencing with IDM taking longer to download the ZIP file may be due to the way IDM handles downloads. IDM may be scanning the file before allowing the download to proceed, which can cause a delay in the download process.

Unfortunately, there is not much you can do in your PHP code to directly address this issue. However, you can try optimizing your ZIP file creation process to reduce the file size and potentially speed up the download process. This can include compressing the files further before adding them to the ZIP archive or optimizing the files themselves to reduce their size.

Additionally, you can try reaching out to IDM support to see if there are any settings or configurations that can be adjusted to improve the download speed for ZIP files. They may have specific recommendations for handling ZIP files more efficiently with IDM.

Rate this post

3 of 5 based on 9858 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us