Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2004, 08:38 AM
Registered User
Join Date: Jan 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Zip file fails with jpg image

I have a weird problem with a web page, Hoping somebody can help.

I use php to create a zip file on the server when the page is requested (can latter be opened fine with winzip) the contents is read back into a variable and is directly sent back to the client after setting the content headers, and will be downloaded by the browser as a zip file. All works fine so far and the received zip file opens fine in winzip

However, if the zip file happens to contain a jpg file of above a certain size, aprox 10-12kb then the received file is corrupt and wont open (the file on the server however is still ok to open with winzip).

I dont think size is an issue as it works fine with large files eg 60Mb, small jpg files eg less than 10kb work fine also. It only seems to affect jpg files over 10-25kb and ONLY when sent directly to the client.

There are obvious work arrounds to this eg. give a link to the zip file on the server but I would rather fix the problem than work arround it.

Here is the code:
header("Content-Type: application/octet-stream zip\r\n");
header("Content-Length: ".filesize('c:\zipfile.zip')."\r\n");
header("Content-Disposition: attachment;

$temp = fopen('c:\zipfile.zip','rb');
$contents = fread($temp,filesize($temp));
print ($contents);

setting application/zip does not work either :-(

Any sugestions apreciated.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XNA doesn't detect .jpg file? jpbaugh BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 September 9th, 2008 09:15 AM
How to display .tif file, .pdf file and .jpg file phuong171 ASP.NET 1.0 and 1.1 Basics 1 March 13th, 2007 07:29 AM
Progressive JPG image vkshrestha ASP.NET 1.x and 2.0 Application Design 2 October 26th, 2006 04:15 PM
WordML image to JPG spencer.clark XSLT 1 June 18th, 2005 06:19 AM
Take Snapshot into JPG file r_s_pathak Visual C++ 0 January 27th, 2005 03:20 AM

All times are GMT -4. The time now is 03:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.