PHP:上传后使用getimageresized调整图像大小后如何使用getimgasize()?

PHP:上传后使用getimageresized调整图像大小后如何使用getimgasize()?,php,file-upload,size,return,image-resizing,Php,File Upload,Size,Return,Image Resizing,使用中给出的示例。。。之后如何使用getimagesize()函数获取图像大小 代码: 我只想得到图像的大小。。。。此外,是否可以执行以下操作: $\u FILES['images']['tmp\u name']=$新调整大小的\u图像\u从\u PHP\u dot\u NET\u代码返回\u。。。。因此['images']['tmp_name']现在将此新图像作为源图像 非常感谢您的任何建议……我决定花点时间研究一下您的问题。我发现,我不认为您需要像您那样通过imagejpeg()返回调整

使用中给出的示例。。。之后如何使用
getimagesize()
函数获取图像大小

代码:


我只想得到
图像的
大小
。。。。此外,是否可以执行以下操作:

$\u FILES['images']['tmp\u name']=$新调整大小的\u图像\u从\u PHP\u dot\u NET\u代码返回\u。。。。因此
['images']['tmp_name']
现在将此新图像作为源图像


非常感谢您的任何建议……

我决定花点时间研究一下您的问题。我发现,我不认为您需要像您那样通过
imagejpeg()
返回调整大小的图像。在调用
函数中的
imagejpeg()
后,可能还需要添加
imagedestroy()
,以销毁所使用的临时内存

在调整图像大小之前,您需要先完全上传图像。如果您愿意,您可以在执行任何操作时将图像发送到临时存储器中,这样Php就不必以
'tmp_name'
格式处理它……然后您可以稍后销毁图像

一旦图像完全上传,事情就变得容易了。代码可能类似于:

        if(isset($_FILES['images'])){

        //may be some random numbers to accompany it.
        $rand = floor((mt_rand()+rand()+mt_rand())/3);

//Send it to the temporary folder you have had to create.
        if(move_uploaded_file(
                    $_FILES['images']['tmp_name'],'temporary_storage/image_'.$rand.'.jpg')){

        //Then run the `resize` function from here.
        $image_resized = resize_this_image_now('temporary_storage/image_'.$rand.'.jpg');

        //Now You can get the size if you wish.         
        list($width,$height) = getimagesize('temporary_storage/image_'.$rand.'.jpg');   

        // Out put

        echo "W:".$width."<br>H:".$height;

        //After you use it as desired, you can now destroy it using unlink or so.

unlink('temporary_storage/image_'.$rand.'.jpg');

            }else{
    echo "Upload Error goes here";
    }

        }
if(isset($\u文件['images'])){
//可能会有一些随机数伴随它。
$rand=地板((mt_rand()+rand()+mt_rand())/3);
//将其发送到您必须创建的临时文件夹。
如果(移动上传的文件)(
$\u文件['images']['tmp\u name'],'temporary\u storage/image.'$rand..jpg')){
//然后从这里运行'resize'函数。
$image\u resized=立即调整此图像的大小('temporary\u storage/image'.$rand..jpg');
//现在,如果你愿意,你可以得到这个尺寸。
列表($width,$height)=getimagesize('temporary_storage/image.'.$rand..jpg');
//发出
回声“W:.$宽度。”
H:.$高度; //按需要使用它之后,现在可以使用unlink或其他方法销毁它。 取消链接('temporary_storage/image.$rand..jpg'); }否则{ echo“上传错误出现在此处”; } }
注意:这个答案是经过多次尝试和错误后得出的。。。请明智地使用这个策略


希望有帮助。

工作了,工作了,工作了。。。非常感谢你。虽然我不理解
列表
这件事。我堆叠到数组中。比如:
$new\u image=getimagesize('temporary\u storage/image.'$rand..jpg')然后我将其命名为:echo
$new\u image[0]或[1]或[n]
。它正确地工作了。谢谢:)酷。。。享受编程!
        if(isset($_FILES['images'])){

        //may be some random numbers to accompany it.
        $rand = floor((mt_rand()+rand()+mt_rand())/3);

//Send it to the temporary folder you have had to create.
        if(move_uploaded_file(
                    $_FILES['images']['tmp_name'],'temporary_storage/image_'.$rand.'.jpg')){

        //Then run the `resize` function from here.
        $image_resized = resize_this_image_now('temporary_storage/image_'.$rand.'.jpg');

        //Now You can get the size if you wish.         
        list($width,$height) = getimagesize('temporary_storage/image_'.$rand.'.jpg');   

        // Out put

        echo "W:".$width."<br>H:".$height;

        //After you use it as desired, you can now destroy it using unlink or so.

unlink('temporary_storage/image_'.$rand.'.jpg');

            }else{
    echo "Upload Error goes here";
    }

        }