开发者

How to name and/or download a dynamic rendered image in PHP to redirect to another page

Ok, I have an API I use that holds a scene file in a dotnet project. I pass it params that adds images to a final image that is rendered out on a webpage. i.e. myserver/GetImage.ashx?param1=value1 which I use link to display an image that is dynamically rendered on my webpage. Value1 = myserver/images/myimage.jpg

My problem is I need to be able to take the result and run it back through the API, so value1 cannot equal myserver/GetImage.ashx?param1=myserver/images/myimage.jpg.

My question is, how can I redirect or store the first result in PHP as FinalRender.开发者_开发问答jpg to run it back through the API, so it would look like myserver/GetImage.ashx?FinalRender.jpg?

I am totally lost so any help would be very appreciated.


Ok, I figured it out.

I created a session ID:

$a = session_id();
if(empty($a)) session_start();

then I grabbed the API image by the HTML ID as shown below:

$a = session_id();


$api_url = 'imgtest2.php';  
$dom = new DOMDocument();
if (@$dom->loadHTMLFile($api_url)) { 
  $img_tag = $dom->getElementById('render'); 
  $src = $img_tag->getAttribute('src'); 
  $img_content = file_get_contents($src); 
  file_put_contents('user/' . $a . "/" . $a . '.jpg', $img_content);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜