문제

I have code as

    <img src="http://www.wiris.net/demo/editor/render.png?mml=<math xmlns='http://www.w3.org/1998/Math/MathML'><mfenced open='[' close=']'><mrow><mi>d</mi><mi>f</mi><mi>g</mi><mi>d</mi><mi>dipen</mi><mi>g</mi></mrow></mfenced></math>"/>

If i put this code in browser i can able to see the one image. I need to store that image in my localhost. I tried GD,Copy(),Curl Image store but nothing helps me.

Please help me guys

Regards Dipen

도움이 되었습니까?

해결책

Try this below functions:

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];
}

e.g. $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')

다른 팁

Javascript!

  • Make a Canvas (drawImage).
  • Get the DataURL - getImageDataURL( jQuery('img#yourimg').attr('src'), function(image) { ajax('post.php', image.data) });
  • AJAX Request to Server, to save the DataURL to a File (file_put_contents('file.png', $_POST['data']))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top