【问题标题】:Resizing remote images and saving it to the server调整远程图像大小并将其保存到服务器
【发布时间】:2011-11-16 15:28:51
【问题描述】:

所以我使用了this guide 并且能够想出这个:

<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菜鸟,所以我希望你能给一些新手友好的解决方案。谢谢你:)

【问题讨论】:

  • 只是在黑暗中拍摄,但如果$imgName 引用远程服务器上的图像,那么$image-&gt;save($imgName) 不会尝试将其保存到远程服务器?
  • 当你说它不保存时,它在做什么?您是否收到错误或图像文件只是没有出现?您的 $imgName 中回显了什么?
  • 那我该怎么办?加载 process.php 后我只是得到一个空白页

标签: php html forms input


【解决方案1】:

如果您能够读取/写入该目录,请检查您的文件夹/文件权限。 如果您没有设置保存新图像的路径,通常它会写入您的 process.php 所在的同一目录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-07
    • 1970-01-01
    • 2021-04-10
    • 1970-01-01
    • 2011-01-25
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多