0
我试图使用PHP文件将图像从URL保存到我的计算机。它适用于我搜索的卡片只有一个名称;然而,当我尝试做它用多个名字的卡片,我得到:使用PHP将图像从URL保存到磁盘
Warning: file_get_contents(http://gatherer.wizards.com/Handlers/Image.ashx?name=black lotus&type=card&.jpg): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\xampp\htdocs\MTGFetcher\results.php on line 6
这是我为我的cardfetch.php代码;
<form action="results.php" method="post">
Name of card: <br>
<input type="text" name="cardname" value="cardresult">
<input type="submit" value="Submit">
</form>
而对于我results.php:
<?php
$results = $_POST['cardname'];
$url = "http://gatherer.wizards.com/Handlers/Image.ashx?name=" . $results . "&type=card&.jpg";
$img = "Pictures/$results.jpg";
file_put_contents($img, file_get_contents($url));
?>
<img src="<?php echo $url ?>">
为什么不与多个单词的工作?
非常感谢,工作! –