PHP Script not proceeding ahead with Amazon S3 Upload -
i trying upload file amazon s3 using aws php sdk whenever try uploading, script gives output till putobject operation no output after operation. not able dump result object. credentials stored in .aws in root folder of test machine (running ubuntu). below code -
$s3 = new aws\s3\s3client([ 'version' => 'latest', 'region' => 'us-east-1' ]); echo "<br />".realpath(upload_dir . $apikey . "/" . $name); try { $result = $s3->putobject([ 'bucket' => 'quicklyusercannedspeechbucket', 'contenttype' => 'text/plain', 'key' => $apikey . "/" . $name, 'sourcefile' => realpath(upload_dir . $apikey . "/" . $name) ]); var_dump($result); } catch(\aws\s3\exception\s3exception $e) { echo $e->getawserrorcode(); } echo "finished"; var_dump($result); when run above code, don't output $result array. idea might happening?
any appreciated ^_^
-pranav
use below code view if image uploaded
try { $result = $s3->putobject([ 'bucket' => 'quicklyusercannedspeechbucket', 'contenttype' => 'text/plain', 'key' => $apikey . "/" . $name, 'sourcefile' => realpath(upload_dir . $apikey . "/" . $name) ]); $s3file='http://quicklyusercannedspeechbucket.s3.amazonaws.com/'.$name; echo "<img src='$s3file'/>"; echo 's3 file url:'.$s3file; var_dump($result); } catch(\aws\s3\exception\s3exception $e) { echo $e->getawserrorcode(); } you can step step detail here amazon s3 file upload using php
Comments
Post a Comment