php - Can I perform such an action with cURL? -
i need give images extension, depending on type , create new name them. can extension before send file server? $_post['image'] url of image. $new_name supposed added while running switch.
$image = $_post['image']; $ch = curl_init($image); curl_setopt($ch, curlopt_header, 0); $imagedata = curl_exec($ch); list($width, $height, $type) = getimagesize($filename); switch ($type) { case 1: ....... //give filename .gif extension , on every filetype } $fp = fopen('../images/' . $new_name, 'wb'); curl_setopt($ch, curlopt_file, $fp); curl_close($ch); fclose($fp); !found answer! (sorry if i'm answering own question wrong (in means of "editing" question), comment on how correctly, if i'm wrong ;)
i need run curl function 2 times, different names. first 1 gets me info file, , second 1 saves wit $new_name
$image = $_post['image'];
$ch = curl_init($image); curl_setopt($ch, curlopt_header, 0); $imagedata = curl_exec($ch); $info = curl_getinfo($ch, curlinfo_content_type); curl_close($ch);
if($info == "image/jpeg") //running code give image appropriate extension...
$cf = curl_init($image); $fp = fopen('../images/' . "image.jpg", 'wb'); curl_setopt($cf, curlopt_file, $fp); curl_exec($cf); curl_close($cf); fclose($fp);
Comments
Post a Comment