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);
#2

[eluser]Otemu[/eluser]
Hi,

If you can copy the link for download and it opens in your browser then there a chance it could be that the adobe package is corrupted on your desktop. Try download the file again but instead of using adobe to open it use your web browser instead.
#3

[eluser]Brad K Morse[/eluser]
Thanks! I think that was the problem. Worked fine in Firefox and in IE, but not Chrome for my Mac.
#4

[eluser]zwadder[/eluser]
I had a problem with downloading xls files, they were corrupted. This did fix it: http://www.innovativephp.com/image-downl...ad-helper/
only added the ob_clean() part to the download_helper and it works now fine.
Only when there is an update I will lose it :-(
#5

[eluser]NeoArc[/eluser]
Try using FCPATH instead of base_url().




Theme © iAndrew 2016 - Forum software by © MyBB