在PHP S3上传中生成缩略图。

时间:2022-10-22 23:06:25

I have a PHP app that uploads an image. I am using the S3 PHP Class (http://undesigned.org.za/2007/10/22/amazon-s3-php-class)

我有一个PHP应用程序上传图片。我使用的是S3 PHP类(http://undesigned.org.za/2007/10/22/amazon-s3-php-class)

Is it possible to create a smaller thumbnail and upload it to S3 as well? I searched the web, but could not find anything.

是否可以创建一个较小的缩略图并将其上传到S3 ?我搜索了网络,但什么也找不到。

Thanks

谢谢

2 个解决方案

#1


2  

Once the file is uploaded to your server, you can do whatever you want with it. PHP will provide you with the temporary location of the uploaded file in the variable $_FILES['your_form_element_name']['tmp_name']

一旦文件被上传到你的服务器,你就可以做任何你想做的事情。PHP将为您提供变量$_FILES中上传文件的临时位置['your_form_element_name']['tmp_name']

From there you can use Imagick to resize the file, and then upload the resized image to S3 alongside your original image.

从那里你可以使用Imagick调整文件大小,然后将调整后的图像上传到S3。

Imagick has a Imagick::thumbnailImage() method which is really easy to use.

Imagick有一个Imagick::thumbnailImage()方法,它很容易使用。

More details on PHP file uploads here: http://www.php.net/manual/en/features.file-upload.post-method.php And more info about how to use Imagick here: http://php.net/manual/en/book.imagick.php

更多关于PHP文件上传的细节:http://www.php.net/manual/en/features.fileupload.postmethod.php和更多关于如何使用Imagick的信息:http://php.net/manual/en/book.imagick.php。

#2


2  

Yes its possible, there are loads of libraries that will resize images for you.

是的,这是可能的,有很多库可以为你调整图像大小。

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

When you've resized the image just upload it in the same way.

当你调整图像大小的时候,就用同样的方法上传。

#1


2  

Once the file is uploaded to your server, you can do whatever you want with it. PHP will provide you with the temporary location of the uploaded file in the variable $_FILES['your_form_element_name']['tmp_name']

一旦文件被上传到你的服务器,你就可以做任何你想做的事情。PHP将为您提供变量$_FILES中上传文件的临时位置['your_form_element_name']['tmp_name']

From there you can use Imagick to resize the file, and then upload the resized image to S3 alongside your original image.

从那里你可以使用Imagick调整文件大小,然后将调整后的图像上传到S3。

Imagick has a Imagick::thumbnailImage() method which is really easy to use.

Imagick有一个Imagick::thumbnailImage()方法,它很容易使用。

More details on PHP file uploads here: http://www.php.net/manual/en/features.file-upload.post-method.php And more info about how to use Imagick here: http://php.net/manual/en/book.imagick.php

更多关于PHP文件上传的细节:http://www.php.net/manual/en/features.fileupload.postmethod.php和更多关于如何使用Imagick的信息:http://php.net/manual/en/book.imagick.php。

#2


2  

Yes its possible, there are loads of libraries that will resize images for you.

是的,这是可能的,有很多库可以为你调整图像大小。

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

When you've resized the image just upload it in the same way.

当你调整图像大小的时候,就用同样的方法上传。

相关文章