I have some code that takes a URL and downloads it using CURL. Here's the code:
$url= $row['loc'];
$path = 'tmp/';
$path .= rand(100,999);
$path .= $row['name'];
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
$downloadarray[] = array($path, $row['name']);
However the file is not correctly downloading as an image even though the filename is, for example paradise-island.jpg. Do I need to specify a minetype somewhere? I belive this is also causing problems further down the code, because despite the fact this code is run twice on separate files this code:
foreach ($downloadarray as $file) {
$zip->addFile($file['0'], $file['1']);
}
is only adding one file to a zip. Does anybody have any ideas? Thanks!