如何使用php从URL下载图像(例如:https://www.google.com/images/srpr/logo3w.png)然后保存它? 这是我到目前为止,它给了我'file_put_contents'函数中的错误。使用php代码从URL下载图片?
<form method="post" action="">
<textarea name="text" cols="60" rows="10">
</textarea><br/>
<input type="submit" class="button" value="submit" />
</form>
<?php
$img = "no image";
if (isset($_POST['text']))
{
$content = file_get_contents($_POST['text']);
$img_path = '/images/';
file_put_contents($img_path, $content);
$img = "<img src=\"".$img_path."\"/>";
}
echo $img;
?>
它给我的错误:
[function.file-put-contents]: failed to open stream: No such file or directory in C:\wamp\www\img.php
的/images/
目录位于php文件的同一目录和可写。
4分钟1答案!!希望你的问题很快解决。 – 2012-03-21 09:12:22
你从未接受过任何答案?请提供并接受帮助你的答案。 – 2012-03-21 09:14:46
@Rohit对不起,但我该如何接受答案? – Sarah 2012-03-21 09:23:37