Shahzeb Khan
Shahzeb Khan

Reputation: 3642

File with large size does not download with php

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,

Upvotes: 0

Views: 1376

Answers (1)

Drahcir
Drahcir

Reputation: 11982

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.

Upvotes: 2

Related Questions