我正在使用 ec2 并通过 goofys 安装 S3。
/var/image
是挂载目录。
并制定这样的政策。
{
"Id": "idididi",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "sidsidsid",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::qqqqqqq/*",
"Principal": "*"
}
]
}
将图像上传到 php 服务器时,不会生成文件。
这是我制作文件的代码。
function makeFile($name, $type, $tmp) {
$output_dir = "../../../../../../var/image/ffffff/";
//$output_dir = "/var/image/ffffff/";
$unique = time() . "_" . uniqid();
$imageName = str_replace(' ', '-', strtolower($name));
$imageType = strtolower($type);
if ( ($imageType == "image/png") || ($imageType == "image/jpeg") || ($imageType == "image/jpg") ) {
$imageExt = substr($imageName, strrpos($imageName, '.'));
$imageExt = str_replace('.', '', $imageExt);
$fileName = 'image' . $unique . '.' . $imageExt;
$destination = $output_dir . $fileName;
move_uploaded_file($tmp, $destination);
return "https://qqqqqq.s3.ap-northeast-2.amazonaws.com/ffffff/".$fileName;
}
return false;
}
哪个 output_dir 是正确的?
或者如何正确制作文件?