CodeIgniter Forums
File downloader doesnt seem to work - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: File downloader doesnt seem to work (/showthread.php?tid=25166)



File downloader doesnt seem to work - El Forum - 12-03-2009

[eluser]jdav3579[/eluser]
Hi,
I have an internal application that allows the upload and download of zip files. The upload works as when I FTP into the folder and download it using filezilla it is fine, but when I use the following code:
function getfile($filename=null){
if($filename==null){redirect('welcome/download'); }
$string = read_file('./downloads/'.$filename);
force_download($filename, $filename);
}

When I save it on to the computer and try to open it, then I get an error message saying that the file is corrupt or invalid message.

Could it be something to do with headers or anything, or do I need to load a view etc? I have looked on the forums and came across something similar but the fix in the mimes,seemed to have no effect..

Does anyone know why this may be the case?


Also I think it has a problem getting images as well as Zips.

Cheers
John


File downloader doesnt seem to work - El Forum - 12-03-2009

[eluser]jdav3579[/eluser]
Sorry, After a bit of a break, I saw my error, I was putting the filename as the contents rather than the actual contents.. thousand apologies!