Welcome Guest, Not a member yet? Register   Sign In
Dowload helper problem with corrupted .7z and .rar files
#1

[eluser]davlyn[/eluser]
I have posted the problem in detail here:
http://stackoverflow.com/questions/16440...ative-solu

I am using Codeigniter's Download helper for "easy" downloading.
Code:
$this->load->helper('download');
    $file = //get_file_name_from_db
    $data = file_get_contents( upload_path . $file);
    force_download($file, $data);

The problem that I have is that any .zip is downloading correctly while .7z and .rar are not. However when I check the uploaded files to see it they are corrupted or not they are fine (via FTP or in local by simply checking the folders).

To add to the confusion if a file is really small (like 5kb or so) then none of the types (7z and rar) will be corrupted.

For the reference here is the mime types I use in mime.php (that both upload and download helper use)
Code:
'zip'   =>  array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),

'7z'    =>     array('application/x-7z-compressed','application/x-7z',  'application/7z', 'application/force-download', 'application/octet-stream'),

'rar'   =>  array('application/x-rar-compressed','application/x-rar', 'application/rar', 'application/octet-stream')

THe problem might be at two points, either the mime types (which it probably isn't since as noted, on very small file sizes it works). Or the file_get_contents() and the header("Content-Length: ".strlen($data)Wink; which might not be so since regardless of size .zip will always download correctly.

Or might it be a sever config problem? I tested it both on a host and at localhost and they behave the same.

So does anybody knows what the problem is or can they suggest an alternative download script or method I should use?


I would be grateful if anybody could give some suggestion on how to fix this.
#2

[eluser]davlyn[/eluser]
Found the solution. There was an echo of a vraiable I wanted to keep in check some time ago that I forgot to comment out. It was added on top of the file and it caused 7z and rar files to become corrupt, while having no effect on the zip files for some reason.
#3

[eluser]Unknown[/eluser]
If corrupt 7z and RAR archives is the main issue, then I'll recommend you to use a third-party recovery application. You can try <b>SysInfoTools Archive Recovery</b> software to fix your corrupt 7z and RAR archives. A couple of months ago, I also used this application to repair my corrupt 7z archives. I, first, downloaded its demo. It was free. Once I felt satisfied with the results, I purchased the full software.
You may also check its free demo version if corrupt archive is the main problem. Hope the application would help you as it helped me.
Regards.




Theme © iAndrew 2016 - Forum software by © MyBB