0

i have the following script for file download.

function download(){
        $this->file = $this->getFile();
        if($this->filesize <= 0 || $this->filesize == null){
            echo $this->filesize;
        } else {
           set_time_limit(0);

            header('Content-Description: File Transfer');
            header('Content-type:'.$this->contenttype);
            header('Content-Disposition: attachment; filename='.$this->filename.'.'.$this->extension);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            ob_end_clean();
            readfile('/upload/'.$this->fileUid.'.'.$this->extension);
        }

        die();
    }

when i try to download file with small size (in Kbs) file(s) download successfully, but if file size is large i.e greate than 1MB, then file does not downloads properly, the downloaded files size is in Kbs, and files does not open either. Can any one kindly help me in this regards, i tried ob_end_clean() but did not work. Kindly help me. Regards,

Shahzeb Khan
  • 3,582
  • 8
  • 45
  • 79

1 Answers1

2

As I worked out in your question comments, the file does not exist on the server. So the real problem is the upload script.

You should read Common Pitfalls Of File Upload My guess is upload_max_filesize, although it could be any of these pitfalls, depends on the server setup.

Drahcir
  • 11,772
  • 24
  • 86
  • 128
  • so does it mean that upload script is not working for large files? as small files are working fine. – Shahzeb Khan Oct 23 '13 at 21:10
  • this is my upload script [ move_uploaded_file($this->tmp_name, "/home/totalrec/upload/" . $this->fileUid.'.'.$this->ext);] – Shahzeb Khan Oct 23 '13 at 21:11
  • @Shahzeb, you could make use of this **PHP download script**. Works for massively large files with great MIME support. [**Large File Download**](http://stackoverflow.com/questions/3176942/using-php-to-download-files-not-working-on-large-files/21354337#21354337) I checked out this by downloading about 2GB file. It works. – webblover Jan 25 '14 at 18:32