简体   繁体   中英

pass a variable to curl from get request php

<?php
@$test = $GET['link'];
$url = 'http://cf3.fancyimgs.com/310/20130521/367302239598940361_92b5e3190b3f.jpg';
$ch = curl_init($test);
$fc = fopen('c.jpg', 'w+');
curl_setopt($ch, CURLOPT_FILE, $fc);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fc);
?>

this is not working in codeigniter, above is my php code to get image from an url that i passed through GET and am not getting the image from the get request url can anyone help me to solve this..... and below is the link from where i send the image url

<a href="index.php?link=<?php echo $url ;?>">click to download</a>

It should be

$_GET['link']
 ^
 |--- Note the underline 

Not

$GET['link']

And

echo urlencode($url) // would be better approach ... 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM