I was wondering if it was possible to upload say a picture file and a text file and in the script put them into a zip file programatically.
if this is possible could you offer some tips or links please?
regards!
Thank you it looks like ill be reading for a while.
thanks again ,regards
This tells you everything you need to know about zipping with PHP.
Here is an upload tutorial you may find helpful.
http://www.tizag.com/phpT/fileupload.php
You'll have to create a file specific to the user, then add the two files, and finally send it to zip.
Good luck!
ok so to do a zip file through php. correct me if im wrong.
i use fopen to create a zip archive
fclose to close it
then use the ziparchive class to open it again
then use the addfile function to add a file to the archive.
then use close
but anywho, im getting an error when i try to unzip the folder, it is
0x80004005
any idea why this is?
ahh i c, sorry about that. so what should i do? keep posting here? or there.
anyways....my code
if(isset($_POST['upload'])){
$zip_dir = 'packs/zips/';
$license = $_POST['license'];
$title = $_POST['title'];
$title .= '_' . rand(999999,time()) . '.zip';
echo $title;
$zip = new ZipArchive;
$pack = fopen($zip_dir.$title,'wb');
fclose($pack);
$zip->open($zip_dir.$title);
$zip->addFile($license, 'newfile.txt');
$zip->close();
}
?>
<form enctype="multipart/form-data" action="" method="post">
<?php if(file_exists('License.txt'))
{
$combo = '<select name="license">';
$combo .= '<option value="License.txt">License</option>';
$combo .= '</select>';
echo $combo;
}
?>