PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Tot
Forum Newbie
Posts: 3 Joined: Thu Jul 01, 2010 4:25 am
Post
by Tot » Thu Jul 01, 2010 4:33 am
I am having issue downloading documents from my php page. When download a word document it opens it in raw format in the browser?
I'm guessing this is an issue with header types but I'm also unsure if this is a security problem over https too? I think it’s trying to download it via a php page.
This is my header code -
Code: Select all
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' .filesize ($Path) );
header('Content-Type: '.$mime_type);
header('Content-Disposition: attachment; filename="'.$result->fileOriginalName.'"');
readfile(JPATH_BASE.'/uploadfile/documentFile/'.$result->fileName.'');
header("Connection: close");|
I am a php newbie please help.
Many thanks in advance.
Last edited by
Benjamin on Thu Jul 01, 2010 4:51 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
Jade
Forum Regular
Posts: 908 Joined: Sun Dec 29, 2002 5:40 pm
Location: VA
Post
by Jade » Thu Jul 01, 2010 8:52 am
Don't you need this header too?
Code: Select all
header("Content-Type: application/vnd.ms-word");
Tot
Forum Newbie
Posts: 3 Joined: Thu Jul 01, 2010 4:25 am
Post
by Tot » Thu Jul 01, 2010 10:22 am
Yes, although its already included within "$mime_type" above. Which determines which type is required. Thanks for your help though.
Tot
Forum Newbie
Posts: 3 Joined: Thu Jul 01, 2010 4:25 am
Post
by Tot » Fri Jul 02, 2010 5:25 am
I've now fixed the problem. The header code was not being called correctly, it’s now resolved my problem and works perfectly.
Jade
Forum Regular
Posts: 908 Joined: Sun Dec 29, 2002 5:40 pm
Location: VA
Post
by Jade » Fri Jul 02, 2010 8:48 am
Can you post your corrected code so it's available for future reference? Thanks!