Php 调整远程映像的大小并将其保存到服务器
因此,我利用并能够得出以下结论:Php 调整远程映像的大小并将其保存到服务器,php,html,forms,input,Php,Html,Forms,Input,因此,我利用并能够得出以下结论: <html> <head></head> <body> <form action="process.php" method="get"> <input type="text" name="image"/> <input type="submit"/> </form> </body> </html> 我想到了process.php: &l
<html>
<head></head>
<body>
<form action="process.php" method="get">
<input type="text" name="image"/>
<input type="submit"/>
</form>
</body>
</html>
我想到了process.php:
<?php
include("SimpleImage.php");
$imgName = $_GET["image"]; //assuming you used GET request and form submits to http://url/script.php?image=something.jpg
$image = new SimpleImage();
$image->load($imgName);
$image->resizeToWidth(250);
$image->save($imgName);
echo $imgName;
?>
但是有点不对劲。它没有保存图像:(我完全是一个PHP noob,所以我希望您能提供一些新手友好的解决方案。谢谢:)如果您能够在该目录上读/写,请检查您的文件夹/文件权限。
如果您没有设置保存新映像的路径,它通常会写入process.php所在的同一目录。只是瞎猜,但是如果
$imgName
指的是远程服务器上的映像,那么$image->save($imgName)
不会试图将其保存到远程服务器吗?当您说它不保存时,它在干什么?您是否遇到错误,或者图像文件没有出现?你的$imgName中有什么回响?那我该怎么办?加载process.php后,我只得到一个空白页