0

I have a CodeIgniter application with a form in a view. The form accepts files that will then be uploaded to Amazon S3. I am using this library to talk to S3: https://github.com/psugand/CodeIgniter-S3. The script works fine when I upload small files. I originally got an error that said The action you have requested is not allowed. I traced the problem to CSRF protection based on this Action you have requested is not allowed error and set CSRF protection to false. Now, the The action you have requested is not allowed. is gone but the large file still doesn't get uploaded. The file gets uploaded and then the page simply flickers and the form empties itself. Not sure why.

My app runs on an Amazon ElasticBeanstalk 64 bit PHP machine. I experience the same error even on localhost. Here is my code:

View

    <?php echo form_open_multipart('landing/submit'); ?>
        <div class="form-group">
          <label for="exampleInputName">Name</label>
          <input type="text" class="form-control" id="app_name" placeholder="Name" name="name" required>
        </div>
        <div class="form-group">
          <label for="exampleInputEmail1">E-mail</label>
          <input type="text" class="form-control" id="app_email" placeholder="E-mail" name="email">
        </div>
        <div class="form-group">
          <label for="exampleInputPassword1">PM XML File</label>
          <input type="file" class="form-control" id="app_file" name="file" placeholder="File">
        </div>
        <button type="submit" class="btn btn-block btn-orange btn-Submit" name="submit">SUBMIT</button>
        <small id="mail_msg"></small>
      <?php form_close(); ?>

Controller

public function submit()
{
    if (isset($_POST['submit']))
    {
        $name           = $this->input->post('name');
        $email          = $this->input->post('email');
        $fileName       = $_FILES['file']['name'];
        $fileTempName   = $_FILES['file']['tmp_name'];

        $this->load->library('s3');

        $input  = $this->s3->inputFile($fileTempName);
        $result = $this->s3->putObject(
            $input,
            'pmxmls',
            $name . '_' . $email . '_' . $fileName,
            S3::ACL_PUBLIC_READ,
            array(),
            array("Cache-Control" => "max-age=315360000", "Expires" => gmdate("D, d M Y H:i:s T", strtotime("+5 years"))
        ));

        is_integer($result);

        if ($result == '1')
        {
            @session_start();
            $_SESSION['submit'] = true;
            redirect(base_url());
        }
        else
        {
            echo 'There was an error.';
        }
    }
    else
    {
        redirect(base_url());
    }
}
Community
  • 1
  • 1
JackH
  • 4,613
  • 4
  • 36
  • 61

1 Answers1

0

k10gaurav is probably correct.

in the php.ini, please upload_max_filesize, post_max_size, max_input_time, max_execution ...

Be sure to restart apache after you save the new values.

Chemdream
  • 618
  • 2
  • 9
  • 25