Jump to content

Downloading file - Adding HTML to top


pocobueno1388

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/217609-downloading-file-adding-html-to-top/
Share on other sites

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>

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.