[請益] php 抓圖
這是一個測試頁面 我想從google chart上把產生的報表圖片
自動抓取下來 放置指定的位置
但似乎一直無法成功
希望有大大指點我一下 哪裡該需要修改
<form method="post" action="">
<input type="text" name="str"><br/>
<input type="text" name="wid"> x <input type="text" name="hei">g<br/>
<input type="submit">
</form>
<?php
$width=$_POST["wid"];
$height=$_POST["hei"];
$info=$_POST["str"];
$url="<img src=\"https://chart.googleapis.com/chart?chs=" . $width . "x" . $height . "&cht=qr&chl=" . $info ."&choe=UTF-8\">";
function GrabImage($url, $filename=""){
if($url == ""){return false;}
$ext = strrchr($url, ".");
if($ext != ".png" && $ext != ".jpg" && $ext != ".gif"){echo "格式不對";return false;}
if($filename == ""){$filename = time()."$ext";}
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img);
$fp2 = fopen($filename , "a");
fwrite($fp2, $img);
fclose($fp2);
return $filename;
}
GrabImage("","as.png");
echo $url ;
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.16.146
→
11/23 22:57, , 1F
11/23 22:57, 1F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章