Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Problem while downloading an user uploaded file in frontend
 
magentoadmindeveloper
Jr. Member
 
Total Posts:  6
Joined:  2009-09-13
 

Hi all,

In the front end section ,
I am using a phtml file , where all the uploaded files will be listed.
All the (listed) uploaded files will be having a link. In the link , means inside the <a href>. I am calling a javascript function which sets a hidden variable and submits to the same page.Once this hidden variable is set , I am calling a php function which is written in the corresponding class file. Inside the function I am calling the following code

header("Content-Type: $filetype");
header("Content-Disposition: attachment; filename=$file");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");

I need the file to be downloaded with a (save or open) prompt. I am getting the prompt. while I am trying to save the file, I can download the file. But the downloaded file content is having all the html page source with it.

I have tried using ob_start(),ob_end_clean(),ob_clean() etc.. before sending the file/output to the browser Still its not working

the files I am using is present in the following folders

/app/code/local/company/New/Block/New.php(this is the class file where the php function resides)

/app/design/frontend/company/default/template/new/new.phtml(this is the phtml file )

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top