我有一个关于
imagejpeg()
的问题。我知道如何将图像保存/上传到S3。我的问题是,使用imagejpeg调整大小后,只保存到本地目录。我想将其保存到S3中。我正在使用Laravel。这是我的代码。感谢任何帮助。S3配置和路径。
$displaypath = '/cover/uploads/csspreview/';
$s3 = \Storage::disk('s3');
$img = $s3->get($data['uploaded_file_path']);
$im = imagecreatefromstring($img);
$width = imagesx($im);
$height = imagesy($im);
$newwidth = '335';
$newheight = '500';
$tuecolor = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tuecolor, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// the above code is good.
$path = './uploads/csspreview/'; // this is a local path only.
imagejpeg($tuecolor, $path.'/cover.jpg'); //save image as jpg (It will save to the file but I want it to save in s3)
Storage::disk('s3')->put($path.$file, $image);
- Abhinav Vermaimagejpeg($tuecolor,Storage::disk('s3')->put($path.$file, $image))
; - Vergel Andus AranasImagejpeg()
也会保存图像。那么它怎么能保存到s3呢? - Vergel Andus Aranasimagedestroy($tuecolor);
删除本地副本。 - Abhinav Verma