How to remove from S3

I have upload a PHP script file to host documents on S3, while the User can delete the file from the SQL list, but not directly from S3. Is this an easy way, I can add deletion from S3 to the same code as below

The rest of the php script includes s3.php if that helps

$bucket = 'files'; $path = 'file/'; // Can be empty '' if (isset($_GET['id'])) { $id = $_GET['id']; $path .= 'File'.$id.'/'; if (isset($_GET['action'])) { $action = $_GET['action']; if ($action = "deleteFile") { $Fileid = $_GET['Fileid']; $query = "DELETE FROM amazon_upload WHERE Upload_File_Id='".$Fileid."'"; $result = mysql_query($query); if (!$result) { die ("could not query database: <br />".mysql_error()); } $locationHeader = "Location: http://www.website.com/upload.php?id=".$id; header($locationHeader); } } } 
+4
source share
2 answers

it works well

 $s3 = new AmazonS3(); $bucket = 'velobucket'; $folder = 'mydirectory/'; $response = $s3->get_object_list($bucket, array( 'prefix' => $folder )); foreach ($response as $v) { $s3->delete_object($bucket, $v); } 
+2
source

Try

disconnect ()

eg

 $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } 
-3
source

All Articles