I’m trying to create a .zip file from an asset from another server like so:
$url = 'http://thindery.com/jsfiddle/butterfly.jpg';
$path = 'butterfly.zip';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
After I run the script I see the .zip on my server. When I download the .zip and try to open it on my Windows computer I get this error:
Windows cannot open the folder
The compressed (zipped) folder ‘butterfly.zip’ is invalid.
Anybody have an idea why it won’t open?
UPDATE
I understand my mistake here. I can see how my original code was just saving the .jpg as a .zip, instead of putting the .jpg in an archived (zipped) folder.
You really want to do this: