Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2004, 08:38 AM
Registered User
 
Join Date: Jan 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Zip file fails with jpg image

Hi,
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;

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

setting application/zip does not work either :-(

Any sugestions apreciated.







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





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