[英]amazon s3, upload file in folder in bucket
I am trying to upload a file to a folder inside a s3 bucket. 我正在尝试将文件上传到s3存储桶中的文件夹。 I am doing the following in PHP:
我在PHP中执行以下操作:
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$tmp = $_FILES['file']['tmp_name'];
$bucket= $_POST['bucket'];
$actual_image_name = explode('.',$name)[0]."-".time().".".$ext;
$s3->putObjectFile($tmp, $bucket , $actual_image_name, S3::ACL_PUBLIC_READ);
The bucket name is a string sent to PHP and indicates a subfolder using a forward slash: 存储桶名称是发送给PHP的字符串,表示使用正斜杠的子文件夹:
'<bucket name>/<subfolder>'
however, when I upload a new image to my bucket, it is uploaded to the bucket root. 但是,当我将新图像上传到我的存储桶时,它会上传到存储桶根目录。 How can I upload this file to the subfolder in my bucket?
如何将此文件上传到我的存储桶中的子文件夹?
Thx 谢谢
子文件夹的名称应添加到文件名的开头,而不是添加到存储桶名称的末尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.