terrypeck36 Posted December 19, 2006 Share Posted December 19, 2006 i am using a very standard script that works for text files but not jpgs, it does not work for gifs either.the zip is correctly made in a temp directory and i can successfully ftp it and extract intact text files and the jpgs are in the zip, correct original filesize, compressed a little bit but when i extract and open there is no data available or image failed.has anyone ever had this problem??any help would be appreciated here is my code [code]<?phpinclude ('pear/archive_zip.php');// Create instance of Archive_Zip class, and pass the name of our zipfile$zipfile = New Archive_Zip('myzipfile.zip');// Create a list of files and directories$list = array('test.txt', 'pic.jpg');// Get temporary directoryif (!empty($_ENV['TMP'])) { $tempdir = $_ENV['TMP'];} elseif (!empty($_ENV['TMPDIR'])) { $tempdir = $_ENV['TMPDIR'];} elseif (!empty($_ENV['TEMP'])) { $tempdir = $_ENV['TEMP'];} else { $tempdir = dirname(tempnam('', 'na'));}if (empty($tempdir)) { die ('No temporary directory'); }// Make sure trailing slash is there$tempdir = rtrim($tempdir, '/');$tempdir .= '/';// Make sure temporary directory is writableif (is_writable($tempdir) == false) { die ('Temporary directory isn\'t writable');}// Create temp name for our own directory$dir = tempnam($tempdir, 'temp');// Make sure another file or directory doesn't already exist with this name@unlink($dir);@rmdir($dir);// Create directorymkdir($dir);$dir .= '/';// Copy files & directories so relative paths still workforeach ($list as $item) { if (is_file($item)) { // Copy file copy ($item, $dir . $item); } elseif (is_dir ($item)) { // Copy directory move_directory ($item, $dir . $item, true); } else { // Invalid file, just ignore continue; }}// Change current working directory, so that the zip file gets created in the temp dirchdir($dir);// Create the zip file$zipfile->create($list);echo 'Zip file created in ' . $dir;[/code] Link to comment https://forums.phpfreaks.com/topic/31202-php-zipping-jpgs-on-the-fly/ Share on other sites More sharing options...
trq Posted December 19, 2006 Share Posted December 19, 2006 Can't really be of much help seeing as Archive_Zip() isn't a native php object. Link to comment https://forums.phpfreaks.com/topic/31202-php-zipping-jpgs-on-the-fly/#findComment-144249 Share on other sites More sharing options...
terrypeck36 Posted December 19, 2006 Author Share Posted December 19, 2006 hi thorpe is there a solid, easy to configure php object class or script that you would suggest?ive tried a few but have genreally had the same problem, txt files work, graphic files do not Link to comment https://forums.phpfreaks.com/topic/31202-php-zipping-jpgs-on-the-fly/#findComment-144270 Share on other sites More sharing options...
trq Posted December 19, 2006 Share Posted December 19, 2006 Whats wrong with php's native [url=http://www.php.net/zip]zip[/url] extension? I would assume these classes use it internally anyway. Link to comment https://forums.phpfreaks.com/topic/31202-php-zipping-jpgs-on-the-fly/#findComment-144272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.