Welcome Guest, Not a member yet? Register   Sign In
Problem during downloading a file
#1

[eluser]Unknown[/eluser]
I don’t have much experience in working with CodeIgniter, but recently I’m using CodeIgniter in one of my company projects. I need help in Downloading a file.

I uploaded a file to a directory at the root of the CI with the do_upload(). The upload is working fine and when I downloaded the file from the directory using a ftp client the file is readable and ok.

But when I used the Download helper and tried to download as follows:
Code:
$data = file_get_contents("./uploads/{$file_name}");
$name = $file_name;

force_download($name, $data);

the download occurs but the file gets changed. i.e. if I download a .doc file, when I open it, it gives me some gibberish texts and tells to select a encoding type.

is this the right way to do it? or should I just provide direct link to the file to make it download than using the download helper?

Thanks.
#2

[eluser]InsiteFX[/eluser]
Try this.
Code:
$data = file_get_contents("./uploads/".$file_name);

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB