Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在服务器上旋转图像,然后将其保存回初始url?_Php_Image_Image Processing_File Upload_Rotation - Fatal编程技术网

Php 如何在服务器上旋转图像,然后将其保存回初始url?

Php 如何在服务器上旋转图像,然后将其保存回初始url?,php,image,image-processing,file-upload,rotation,Php,Image,Image Processing,File Upload,Rotation,我的目标是能够从我的服务器上的url中提取图像,将该图像旋转90度,然后将其保存回我从中提取图像的url 我尝试过很多不同的方法,但都不管用 这就是我目前拥有的: $imurl = "../images/sample.jpg"; $file = fopen($imurl, "rb"); $rotim = imagerotate($file, 90, 0); move_uploaded_file($rotim, $imurl); 我不确定这是否会改变什么,但图片url与

我的目标是能够从我的服务器上的url中提取图像,将该图像旋转90度,然后将其保存回我从中提取图像的url

我尝试过很多不同的方法,但都不管用

这就是我目前拥有的:

$imurl = "../images/sample.jpg";
$file = fopen($imurl, "rb");        
$rotim = imagerotate($file, 90, 0);     
move_uploaded_file($rotim, $imurl);
我不确定这是否会改变什么,但图片url与当前文件不在同一目录中

我一直在这两种链接格式之间交替使用-两者似乎都不起作用

$imurl = "https://www.site.com/images/1/picture.jpg"

$imurl = "../images/1/picture"
你的90%在那里

$imurl = "../images/sample.jpg";
$file = imagecreatefromjpeg($imurl); //http://nz2.php.net/manual/en/function.imagecreatefromjpeg.php
$rotim = imagerotate($file, 90, 0);   //http://nz2.php.net/manual/en/function.imagerotate.php      
imagejpeg($rotim, $imurl); //http://nz2.php.net/manual/en/function.imagejpeg.php

注意相对路径,我更喜欢尽可能使用完整路径。

语法错误。缺少引号。另外,您没有使用url,而是使用目录(路径)。它仍然打开了文件句柄。您也必须关闭它。您不想移动\u上传\u文件。您可以发布这样的正确代码吗?感谢您的回复,当我将此代码放入时,它返回三个错误:1。imagecreatefromjpeg->无法打开流2。imagerotate->期望参数1为资源,布尔值为3。imagejpeg->期望参数1为resource,布尔值给定所有与第一个相关的参数,图像不在您所说的位置。我已将url更改为所有可能的类型,并且仍然不工作,相同的错误如果您使用url,则需要启用fopen包装器,但上面不是url,而是文件路径,所以我不知道你在干什么。将文件放在与脚本相同的目录中,并使用
$imurl=“sample.jpg”