duanchongzi9997 2015-01-03 15:01 采纳率: 0%
浏览 84
已采纳

亚马逊s3,上传文件夹中的文件

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

  • 写回答

1条回答 默认 最新

  • doujiao1948 2015-01-03 17:06
    关注

    The name of the sub folder should be added to the beginning of the filename and not to the end of the bucket name.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊