Error reading zip

Reply

Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Error reading zip

 
0
  #1
Apr 19th, 2005
I have this function whereby it allows people to download zip file but then i try to open it after downloading it, there was this error msg that says "Error reading zip".
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Error reading zip

 
0
  #2
Apr 19th, 2005
If you really want help you should post your code, or at least the portion you feel is causing the problem. Offhand it sounds like the zip file on the server has gotten corrupted somehow.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #3
Apr 19th, 2005
[PHP] $zipfile = new zipfile();
$zipfile -> add_dir("files/");
$dir = '../files';

$filename = "testing.mp3";
$pathname = "$dir/$filename";

$fr = fopen($pathname, 'r');
$data = fread($fr, filesize($pathname));

fclose($fr);

$zipfile->add_file($filedata, "files/".$filename);



header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=testing.zip");
echo $zipfile->file();


[/PHP]



This is the part i feel is causing the problem. i have a zipfile class which creates zip files
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Error reading zip

 
0
  #4
Apr 20th, 2005
Have you tried:

[PHP]header("Content-type: application/x-zip");[/PHP]

Also, you open the file and put the data into $data. Then you use the class and use the variable $filedata. Should they be the same??
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #5
Apr 20th, 2005
Originally Posted by DanceInstructor
Have you tried:

[PHP]header("Content-type: application/x-zip");[/PHP]

Also, you open the file and put the data into $data. Then you use the class and use the variable $filedata. Should they be the same??
oh that, it's the same, i forget to change it because these codes are edited to protect the privacy of the codes.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #6
Apr 24th, 2005
i try already but cannot still error reading zip but the file was in the downloaded because i see the file size of the zip is the same as the file size of the file.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: Error reading zip

 
0
  #7
Apr 26th, 2005
Hi

You should be using a content length header so the browser does not add \r?\n to the stream buffer...

Also your application-x-type is wrong...

  1. if ( strstr ( strtolower ( $_SERVER['HTTP_USER_AGENT'] ), 'msie 5.5' ) )
  2. {
  3. $att = '';
  4. }
  5. else
  6. {
  7. $att = ' attachment;';
  8. }
  9.  
  10. header ( 'Cache-control: max-age=31536000' );
  11. header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
  12. header ( 'Content-Length: ' . filesize ( $filename ) );
  13. header ( 'Content-Type: application/x-zip-compressed; name="' . basename ( $filename ) . '"' );
  14. header ( 'Content-Disposition:' . $att . ' filename="' . basename ( $filename ) . '"' );
  15. header ( 'Content-Transfer-Encoding: binary' );
  16. readfile ( $filename );

demo
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #8
Apr 26th, 2005
so this codes are the correct one then? oh k i will try n see then thanks :cheesy:
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #9
Apr 26th, 2005
Originally Posted by demo
Hi

You should be using a content length header so the browser does not add \r?\n to the stream buffer...

Also your application-x-type is wrong...

  1. if ( strstr ( strtolower ( $_SERVER['HTTP_USER_AGENT'] ), 'msie 5.5' ) )
  2. {
  3. $att = '';
  4. }
  5. else
  6. {
  7. $att = ' attachment;';
  8. }
  9.  
  10. header ( 'Cache-control: max-age=31536000' );
  11. header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
  12. header ( 'Content-Length: ' . filesize ( $filename ) );
  13. header ( 'Content-Type: application/x-zip-compressed; name="' . basename ( $filename ) . '"' );
  14. header ( 'Content-Disposition:' . $att . ' filename="' . basename ( $filename ) . '"' );
  15. header ( 'Content-Transfer-Encoding: binary' );
  16. readfile ( $filename );

demo
by using basename, other ppl can know what is the location of the mp3 but for security purposes, i dun want ppl to know the location of the mp3
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 44
Reputation: starsunited is an unknown quantity at this point 
Solved Threads: 1
starsunited's Avatar
starsunited starsunited is offline Offline
Light Poster

Re: Error reading zip

 
0
  #10
Apr 27th, 2005
i did not use zip file anymore then can work already. i am able to download the file successfully. the next problem arises up.

In the first place, the mp3 file has a ID3 tag. after it has been downloaded, the ID3 tag is deleted. I figure it must be the codinng though because when i download it straight from server through ftp. Everything is alright. i myself really do not know what is wrong.

This is the part of code which i think might be the problem

$currentdir = '../mp3_files';
$trackname = $trackdb->retrieveTrackName($track_oid);
$filename = "$trackname.mp3";
$pathname = "$currentdir/$filename";

$fr = fopen($pathname, 'r');
$filedata = fread($fr, filesize($pathname));

//fclose($fr);


//$zipfile->add_file($filedata,$filename);

header ( 'Content-Length: ' . filesize ( $pathname ) );
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=$filename");
header ( 'Content-Transfer-Encoding: binary' );
readfile($pathname);
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC