doujianzhi3358 2011-04-30 01:56
浏览 44
已采纳

如何在PHP中命名和/或下载动态呈现图像以重定向到另一个页面

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.

  • 写回答

1条回答 默认 最新

  • douchunjing6587 2011-05-07 22:26
    关注

    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);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写