pocobueno1388 Posted November 2, 2010 Share Posted November 2, 2010 I have a script that will download a file from my server onto the user's computer. The problem is it's adding the pages HTML to the top of the file. When I actually look at the file on my server it does NOT have the HTML there, so it has to be some sort of problem with my headers. <?php $fname = "keyword_files/".$this->fileID.".csv"; header('Content-type: application/csv'); header("Content-Disposition: inline; filename=".$fname); readfile($fname); ?> I would appreciate any help! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/217609-downloading-file-adding-html-to-top/ Share on other sites More sharing options...
Airzooka Posted November 3, 2010 Share Posted November 3, 2010 Is there anything else in the file that retrieves the file you want to give to the user? If you have something like this, then it might include the HTML at the top of the page, too. <html> <head> <titleOhai!</title> </head> <?php // Headers to send file, etc ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217609-downloading-file-adding-html-to-top/#findComment-1129724 Share on other sites More sharing options...
pocobueno1388 Posted November 3, 2010 Author Share Posted November 3, 2010 You're right, it's because there was HTML above the headers. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/217609-downloading-file-adding-html-to-top/#findComment-1129735 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.