php초보입니다 ㅜㅜ s3 upload 연습중인데요. 하나는 들어가지만
다중업로드를 하려는데 잘안되네요 ,, 어디가 잘못되었는지 부탁드립니다!
require 'vendor/autoload.php';
$error = $_FILES['userfile[]']['error'];
$name = $_FILES['userfile[]']['name'];
$type = $_FILES['userfile[]']['type'];
$ext = array_pop(explode('.', $name));
$bucket = 'test';
$keyname = 'testup';
$filepath = 'testup/';
$s3Client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'ap-northeast-2',
'credentials' => [
'key' => '**************',
'secret' => '*****************************',
],
]);
$params = [
'Bucket' => $bucket,
'Key' => $name,
'Body' => $ext,
'ACL' => 'public-read',
'ContentType' => $type
];
$result = $s3Client->putObject($params);
$command = $s3Client->getCommand('PutObject', $params);
header('Location:/upload');
}
실제로 만들어보시면 단순 루프만이 아니라 좀더 생각 할것들이 있습니다 ^^
라이브러리로 한번 만들어 보심을 추천드립니다.
@ kaido
네 답변갑사합니다!ㅎㅎ 연습해보겠습니다!
기본적인걸 까먹고 고민만했네요 ^^;
혹시 저처럼 고민하시는분들은 foreach 반복문으로 돌리면됩니다!