试试下面的功能:
function grabLiveImage($imgUrl,$pathToSave,$filename='')
{
$data = file_get_contents($imgUrl);
if($filename == '')
$filename = getFilename($imgUrl);
$fp = fopen($pathToSave.$filename, 'w+');
fputs($fp, $data);
fclose($fp);
return $filename;
}
function getFilename($url)
{
$basename = basename($url);
$temp = explode('?',$basename);
return $temp[0];
}
例如 $url = 'http://www.wiris.net/demo/editor/render.png?mml=%3Cmath%20xmlns=%27http://www.w3.org/1998/Math/MathML%27%3E %3Cmfenced%20open=%27[%27%20close=%27]%27%3E%3Cmrow%3E%3Cmi%3Ed%3C/mi%3E%3Cmi%3Ef%3C/mi%3E%3Cmi%3Eg%3C /mi%3E%3Cmi%3Ed%3C/mi%3E%3Cmi%3Edipen%3C/mi%3E%3Cmi%3Eg%3C/mi%3E%3C/mrow%3E%3C/mfenced%3E%3C/math %3E';
grabLiveImage($url,'test/','test.jpg')