【问题标题】:How can I save the source of an image tag to a file? [duplicate]如何将图像标签的来源保存到文件中? [复制]
【发布时间】:2014-08-06 05:58:33
【问题描述】:

问题来了:

我正在从图像叠加网络服务获取流。

字符串是这样的:

$string = http://[ipaddress]/faceCrop/Z%3A%5Ccelebhair%5CHair2-148_172_278_378.png/Z%3A%5Cprofilepictures%5C9ef14819f0.png/90/40/300/466

然后我像这样渲染图像:

<img src="<?php echo $string;?>">

这会正确显示图像。

但是,我需要将图像(自动)保存到服务器上的文件夹中。

如何使用 PHP 或 Javascript 将数据流保存为物理图像?

谢谢

J

【问题讨论】:

  • 通过 AJAX 将 URL 发送到获取文件并保存的 PHP 脚本。

标签: javascript php


【解决方案1】:

你必须获取文件的内容,然后保存内容..

$fileContent = file_get_contents($url);
file_put_contents($filePath, $fileContent);

【讨论】:

  • 谢谢! @RaggaMuffin-420
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-14
相关资源
最近更新 更多