我有一个CodeIgniter应用程序,在视图中有一个表单。表单接受将上载到Amazon S3的文件。我正在使用这个库与S3交谈:https://github.com/psugand/CodeIgniter-S3。上传小文件时脚本工作正常。我最初收到的错误是不允许您请求的操作。我根据此Action you have requested is not allowed error将问题跟踪到CSRF保护,并将CSRF保护设置为false。现在,不允许您请求的操作。已消失,但大文件仍未上传。文件上传后页面只是闪烁,表单自行清空。不知道为什么。
我的应用程序在Amazon ElasticBeanstalk 64位PHP计算机上运行。我甚至在localhost上遇到了同样的错误。这是我的代码:
查看
<?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(); ?>
控制器
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());
}
}
答案 0 :(得分:0)
k10gaurav可能是正确的。
php.ini中的,请upload_max_filesize,post_max_size,max_input_time,max_execution ...
确保在保存新值后重新启动apache。