我有问题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)