在将数据上传到AWS S3存储桶之前,如何检查目录名称和字符串名称是否相等。当我将数据上传到s3时,我收到错误无效数据。
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'ap-south-1',
'credentials' => [
'key' => 'xxxxx',
'secret' => 'yyyyy',
],
]);
$bucket = "naveen";
$ACL = "public-read";
$path = "/Naveen-Backup/project-requirements/admin";
$file = basename($path);
$BundleFolderName = "admin";
$BundleFile = $_FILES['Bundle']['name'];
$BundlePathToFile = $_FILES['Bundle']['tmp_name'];
$BundleKey = "Bundles/test/${BundleFolderName}/".$BundleFile;
if ($file == $BundleFolderName) {
$admin = 'http://'.$bucket.'.s3.amazonaws.com/'.$BundleKey;
$s3->putObject([
'Bucket' => $bucket,
'Key' => $BundleKey,
'ACL' => $ACL,
'SourceFile' => $iosBundlePathToFile
]);
}
$query = new mysqli(HOSTNAME, USERNAME, PASSWORD, DB) or die('Unable to Connect');
$mydb = "INSERT INTO `admin`( `admin`) VALUES ('$admin')";
if (mysqli_query($query, $mydb)){
echo "upload success";
} else{
echo ("Error description: ".mysqli_error($query));
}
}