Here is my code which works if I run it locally but not if I run on my server to transfer my csv
to s3
using PHP
from my server.
<?php
// Include the AWS SDK using the Composer autoloader.
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$s3 = new S3Client([
'version' => 'latest',
'region' => 'us-east-2'
]);
$bucket = 'edtopia';
$keyname = 'sample_1.csv';
try {
// Upload data.
$result = $s3->putObject(array(
'Bucket' => $bucket,
'Key' => $keyname,
'Body' => fopen('numberclub.org/edtopiadb/df_corr.csv', 'r'),
'ACL' => 'public-read'
));
echo $result['ObjectURL'] . "
";
} catch (S3Exception $e) {
echo $e->getMessage() . "
";
}
EDIT- This now working for me on the server, Now my challenge is to access the file on the local system to be sent to s3 using this php script where in the BODY i need to define my local system file path and this code running on the server. What is the effective way to achieve it