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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.