Welcome Guest, Not a member yet? Register   Sign In
Force download downloads the file but the file is damaged and cant be opened!
#1

[eluser]behnampmdg3[/eluser]
Force download downloads the file but the file is damaged and cant be opened!
Code:
$this->load->helper('download');
  
   $file_name = "file.png";

   $data = base_url('QR_codes/'.$qrcode.".png");
   force_download($file_name, $data);
#2

[eluser]CroNiX[/eluser]
See the example in the manual.
Quote:If you want to download an existing file from your server you'll need to read the file into a string:
You're passing a URL.
#3

[eluser]Tobz[/eluser]
I'm having the same problem.

I've tracked down the issue to a bug in EE 2.9.0 where if exit() is ever called, a string is prepended to your output.
Something like:

Code:
{!-- ra:000000000ae5414d000000008a2c77c5 --}

since exit() is called in the force_download() method, that string is appended to the file output thus corrupting it.

As far as I can tell Ellislab has not said anything about this bug or how to fix it or even acknowledged that it exists.
#4

[eluser]CroNiX[/eluser]
Might want to post that in an EE specific forum for better help.
#5

[eluser]Tobz[/eluser]
Good point - I didn't realize this was a CI thread, yay for everything looking the same.
#6

[eluser]InsiteFX[/eluser]
You need to set the value of upload_max_filesize and post_max_size in your php.ini, they should both be the same size.

Code:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

// Or you can do it using ini
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');

// Or in .htaccess
<IfModule mod_php5.c>
   php_value upload_max_filesize 40M
   php_value post_max_size 40M
</IfModule>




Theme © iAndrew 2016 - Forum software by © MyBB