Reputation: 11
I have used the following code:- when i run this code in EC2 This will upload file upto 2MB but for filesize > 2MB it gives error :- This site can’t be reached The connection was reset. Try:
Checking the connection Checking the proxy and the firewall Running Windows Network Diagnostics ERR_CONNECTION_RESET
I did not get the solution..may be some configuration issue in EC2 or in php-sdk..i have gone through all suggested solution but i did not get exact solution. also tried to set upload_max_filesize = 40M ,post_max_size = 40M parameter of php.ini file.
if(isset($_FILES['image'])){
require 'vendor/autoload.php';
$file_name = $_FILES['image']['name'];
$s3 = new Aws\S3\S3Client([
'region' => 'us-east-1',
'version' => 'latest',
'http' => [
'verify' => false
],
'credentials' => [
'key' => "mykey",
'secret' => "my secret key",
]
]);
// Send a PutObject request and get the result object.
$key = $file_name;
$file = $_FILES["image"]['tmp_name'];
$result = $s3->putObject([
'Bucket' => 'epitahousing',
'Key' => $key,
'SourceFile' => $file,
]);
var_dump("uploaded successfully!!");
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
Upvotes: 0
Views: 632
Reputation: 11
I have come with solution that works for me. I have not configure proxy, just keep wait server to listen till your request come by changing httpd.conf parameter as follow..
RequestReadTimeout header=20-120,MinRate=50 body=20,MinRate=50
Upvotes: 1