Jump to content

How to get return status of "Save-As" dialogue box ?


dhillarun

Recommended Posts

Hi everbody,

 

I am displaying "Save-As" dialogue box

 header("Cache-Control: public, must-revalidate");
        header("Pragma: hack");
        header("Content-Type: " . $this->mime);
        header("Content-Length: " .(string)($fsize) );
        header('Content-Disposition: attachment; filename="'.basename($this->path.$this->name).'"');
        header("Content-Transfer-Encoding: binary\n");

 

using "header()" function.

 

But how to know that user has clicked "save" button or "cancel" button.

 

Pl do reply me.

I am sending the content to the browser as chunks by chunks by using the following function.

 

I tried to check whether no. of bytes sent to browser is equal to original file size.

 

But it's not working.

 

Pl specify any other better way to achieve the same. (i.e)I want to know success or failure in delivery of whole downloading file .

 


function readfile_chunked($filename)
    {
        $chunksize = 1*(1024*1024); // how many bytes per chunk
        $buffer = '';
        $cnt =0;

        $handle = fopen($filename, 'rb');

        if ($handle === false)
        {
                return 0;
        }

        while (!feof($handle))
        {
                $buffer = fread($handle, $chunksize);

                if(print $buffer)
                {
                $cnt += strlen($buffer);
                }

        }

         fclose($handle);

         return $cnt;

    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.