Welcome Guest, Not a member yet? Register   Sign In
Download helper, using force_download() - file corrupt after opening it
#1

[eluser]Brad K Morse[/eluser]
I manually uploaded files to a server using Transmit, auto detect (file settings).

Then I use the download helper lib to force download the file when a user clicks on a link, which ties to the file's ID in the database.

If I go directly to the file URL path, for example: domain.com/directory/file.pdf, it shows up fine in the browser.

When I click the link that downloads that same file to my desktop, then I open it, it says it is corrupted. This happens to all the files.

What might be possible causes to this problem?

Code:
$this->load->helper('download');
$document = $this->documents->get_document($id);

$data = file_get_contents(base_url() . "uploads/" . $document->file_name);
$name = $document->file_name;

force_download($name, $data);


Messages In This Thread
Download helper, using force_download() - file corrupt after opening it - by El Forum - 06-21-2012, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB