简体   繁体   中英

amazon s3, upload file in folder in bucket

I am trying to upload a file to a folder inside a s3 bucket. I am doing the following in 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:

'<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

子文件夹的名称应添加到文件名的开头,而不是添加到存储桶名称的末尾。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM