Zubrag.com
September 22, 2018, 01:13:30 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: File does not exist. large iso image  (Read 5347 times)
memmas
Newbie
*
Posts: 3


« on: April 17, 2012, 10:20:41 AM »

Hello,
I'm using your script, and although it works with small files (zip, md5 e.tc.) I have a problem with one iso image which is 4GB.
I'm getting
"File does not exist. Make sure you specified correct file name."

any help?

Thanks

Logged
memmas
Newbie
*
Posts: 3


« Reply #1 on: April 17, 2012, 10:24:52 PM »

After google a lot, I made some progress understanding the problem, it seems is_file() has a problem with large files.
Also
$fsize = filesize($file_path);
doesn't work for me  either... so I replace it with
$fsize = trim(`stat -c%s $file_path`);

So I replace
if (!is_file($file_path)) {
with
if (!file_exists($file_path)) {

Small files continues to download correct, large iso image download now, but I get a 0KB file. Sad

Has anyone find a solution for that?
Logged
memmas
Newbie
*
Posts: 3


« Reply #2 on: April 18, 2012, 06:07:48 AM »

It seems the problem now is fopen() readfile() and 2GB+ files, which php can't open.
So since my path it's on htdocs dir I just add in headers
Code:
header("Location: " . $file_path);

and to keep small files under 2GB to use the old way I change last part
Code:
if ($file) {
  while(!feof($file)) {
    print(fread($file, 1024*8));
echo $file;
   flush();
    if (connection_status()!=0) {
      @fclose($file);
      die();
    }
  }
  @fclose($file);
}
}
to

Code:
if (!fread($file, 8192)) {

//header_remove();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
header("Location: " . $file_path);

} else {
//header_remove();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);

if ($file) {
  while(!feof($file)) {
    print(fread($file, 1024*8));
echo $file;
   flush();
    if (connection_status()!=0) {
      @fclose($file);
      die();
    }
  }
  @fclose($file);
}
}

header_remove();  function only works since php-5.3, but it seems to work, without it...

Thanks for this great script
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC