kid304 Posted December 12, 2009 Share Posted December 12, 2009 I have a very small segment code below : header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: $content_type'); header("Content-Disposition: attachment; filename=\"$name\";\n\n"); header('Content-Length: ' . filesize($link)); readfile($link); $link is the real path to my file. when I test that file without "include" command, it work fine. but when I add "include" command, the file I download from server can't open (too many strange characters...). Could you provide me another way to solve my problem.? (All I need : 1 simple script which allow download "printable documents" and this script allow me add "include" command ) PS: I use include command to import a class help me query data more easily ! Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/ Share on other sites More sharing options...
mrMarcus Posted December 12, 2009 Share Posted December 12, 2009 i don't see you including anything in this code. i'm not following. Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/#findComment-976025 Share on other sites More sharing options...
kid304 Posted December 12, 2009 Author Share Posted December 12, 2009 Hi guy, I just extract a piece of code, if I add include like this: include("mysql_class.php"); When I download file, That file will be wrong. (You can't understand content of that documents) Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/#findComment-976033 Share on other sites More sharing options...
mrMarcus Posted December 12, 2009 Share Posted December 12, 2009 Hi guy, I just extract a piece of code, if I add include like this: include("mysql_class.php"); When I download file, That file will be wrong. (You can't understand content of that documents) i don't understand contents of this post to be honest. there's obviously something wrong with mysql_class.php that's causing your script to fail. but since i won't understand the contents of your extreme script, i guess i can't be of any help to you. Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/#findComment-976040 Share on other sites More sharing options...
ignace Posted December 12, 2009 Share Posted December 12, 2009 You can't understand content of that documents You can bet my ASCII editor will Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/#findComment-976059 Share on other sites More sharing options...
kid304 Posted December 12, 2009 Author Share Posted December 12, 2009 Sorry, You will understand what I want to ask right now: The first page: page1.php: <? echo "hello word"; ?> And the second: page2.php: <? ob_start(); include("page1.php"); $link="ShellProgramming.doc"; $name='example.doc'; $content_type='application/msword'; header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: $content_type'); header("Content-Disposition: attachment; filename=\"$name\";\n\n"); header('Content-Length: ' . filesize($link)); readfile($link); ?> Explain: I have a document named: ShellProgramming.doc I write script above to download that document. but when I download that document, I can't read it. if I throw away: ob_start(); include("page1.php"); it will work fine. (ob_start() avoid "header error" only ) Help me solve problem ! Thanks so much ! Quote Link to comment https://forums.phpfreaks.com/topic/184889-problem-with-dowloading-page/#findComment-976082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.