0

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>
  • @Lawrence Cherone I have gone through that but it is not working... – Ankit Dwivedi Jul 01 '19 at 09:43
  • Make sure to restart apache/php-fpm after config changes, What's your error log show? – Lawrence Cherone Jul 01 '19 at 09:48
  • @Lawrence Cherone error is [proxy_fcgi:error] [pid 3127] (70007)The timeout specified has expired: [client XXX.XXX.XXX] AH01075: Error dispatching request to : (reading input brigade), referer: http://ec2-52-210-85-161.eu-west-1.compute.amazonaws.com/upload/fileupload.php – Ankit Dwivedi Jul 04 '19 at 11:20

1 Answers1

1

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