0

here is my code:

ob_start();
$mm_type="application/octet-stream";
$file = '../uploads/files/' . $filename;

header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($file)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");

ob_end_clean();

readfile($file);

the script triggers the download but the file is not the right size. My file must be 17Mo, but i download a 64Kb file each time. I placed this line above my script:

$file = '../uploads/files/' . $filename;
echo "FileSize: " . filesize($file);
exit();

And it display 17566342, the right size.

This issue appear when i made a big mistake on plesk, i ran this command:

chown -R 10003:1003 /

All my system was down, i could repair it by update plesk and ran:

plesk repair fs

But since then, my download script doesn't work properly.

I checked rights, my uploads dir is 755, my files dir is set to 755 too, and the file is set on 644.

GabrieleMartini
  • 1,665
  • 2
  • 19
  • 26
Alexking2005
  • 325
  • 1
  • 4
  • 16
  • Check your php [post size](https://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size) – Sebastian Waldbauer Jan 20 '19 at 16:29
  • @SebastianWaldbauer , i don't use POST method here, but i checked and my post_size is set to 32M – Alexking2005 Jan 20 '19 at 17:16
  • Oh, sorry misinterpreted your question *urg*. ```header("Content-Length: " .(string)(filesize($file)) );``` doenst need to be a string. [Maybe your solution?](https://stackoverflow.com/questions/7263923/how-to-force-file-download-with-php) – Sebastian Waldbauer Jan 20 '19 at 17:20

0 Answers0