我想将图像上传到S3,但图像正在上传,但大小为0字节,与源文件不同。不知道我做错了什么,任何人都可以指导我正确的方向请。使用AWS PHP SDK将图像保存到S3
upload.php的低于
<!DOCTYPE html>
<html>
<body>
<form action="save.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
save.php
<?php
include 'connecttoaws.php'
$bucket = 'xyxdskjflsdafjsakf';
$file = $FILES["img"]["name"];
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["img"]["tmp_name"]);
if($check !== false) {
$uploadOK = 1;
$result = $client->putObject(array(
'Bucket' => $bucket,
'ContentType' => 'image/png',
'Key' => $file
));
echo 'Image Uploaded';
}
else{
echo "File not uploaded";
$uploadOK = 0;
}
输出:
图片上传
的文件是可在S3上,但大小为0。我究竟做错了什么?