Reputation: 19366
I have an image resource that is manipulated with imagecopyresampled
. I need to pass that image to a set of methods that expect a string input, not a resource. But I don't need to store the file locally.
Is this the proper way:
imagepng
and imagejpeg
@unlink
Is that right? Seems sloppy.
Note: the image is not coming from a file upload and hence can't be accessed with $_FILES["Filedata"]["tmp_name"]
Upvotes: 1
Views: 1743
Reputation: 1469
I took a look at the Amazon S3 PHP API: http://docs.amazonwebservices.com/AWSSDKforPHP/latest/index.html#m=AmazonS3/upload_part
I assume you are using something like the upload_part
method that takes a string filename
. In that case, unless you plan to modify their library, you will need to store the file to disk and pass them the filename so they can read the file and perform the upload.
Besides the steps mentioned in your question you can take a look at imagedestroy
to make sure you are freeing up the memory for your image resource after it is written to disk with imagepng
. And then, as you stated, you can delete your temp file with unlink
after your upload is complete.
I agree, it does seem a bit wasteful, but in this case necessary since the API doesn't seem to provide an alternative.
Upvotes: 1