问题描述
我使用Plupload来管理我的网站的文件上传。当我配置Plupload发布到以下测试文件时,记录显示正确,但是当我发布到CI控制器时,$ _POST和$ _FILES都是空的。
test.php
<?php print_r($ _ FILES); print_r($ _ POST); >
当使用标准HTML表单时,CI会正确显示$ _FILES和$ _POST数组,是什么原因造成的?
EDIT
这里是plupload config
var uploader = new plupload.Uploader({
runtimes:'html5,html4,flash,silverlight,browserplus',
browse_button:'pickfiles',
container:'container',
max_file_size:'15mb',
url:'/test.php',
// url:'/ upload / do_upload /',
flash_swf_url:'/js/plupload/plupload.flash.swf',
silverlight_xap_url:'/js/plupload/plupload.silverlight.xap',
filters:[
{title:Documents ,extensions:pdf,doc,docx,rtf,txt}
],
multipart_params:{job:-2}
}
这里是控制器
class上传扩展CI_Controller {
function __construct()
{
parent :: __ construct
}
function index()
{
$ this-> load-> view('upload_form',array('error'=> '));
}
function do_upload()
{
print_r($ _ POST);
print_r($ _ FILES);
$ config ['upload_path'] ='incoming /';
$ config ['allowed_types'] ='pdf | doc | docx | rtf | txt';
$ config ['max_size'] ='900';
$ this-> load-> library('upload');
$ this-> upload-> initialize($ config); //必须调用ELSE配置未加载
if(!$ this-> upload-> do_upload()){
$ error = array('error'=> $ this - > upload-> display_errors());
$ this-> load-> view('upload_form',$ error);
}
else {
$ data = array('upload_data'=> $ this-> upload-> data());
$ this-> load-> model('translation_model');
$ this-> translation_model-> add_orig($ job,$ filePath);
$ this-> load-> view('upload_success',$ data);
}
}
}
最可能的原因是错误的mod重写规则。如果您正在使用任何网址,请尝试停用这些网址,然后再次发布您的数据。
I'm using Plupload to manage file uploads for my site. When I configure Plupload to post to the following test file, the records are shown correctly, however when I post to a CI controller, both $_POST AND $_FILES are empty.
test.php
<?php print_r($_FILES); print_r($_POST); ?>
CI does correctly display the $_FILES and $_POST arrays when using a standard HTML form, so any ideas what's causing this?
EDIThere is the plupload config
var uploader = new plupload.Uploader({
runtimes : 'html5,html4,flash,silverlight,browserplus',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '15mb',
url : '/test.php',
//url : '/upload/do_upload/',
flash_swf_url : '/js/plupload/plupload.flash.swf',
silverlight_xap_url : '/js/plupload/plupload.silverlight.xap',
filters : [
{title : "Documents", extensions : "pdf,doc,docx,rtf,txt"}
],
multipart_params : { job : -2 }
});
and here is the controller
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
function do_upload()
{
print_r($_POST);
print_r($_FILES);
$config['upload_path'] = 'incoming/';
$config['allowed_types'] = 'pdf|doc|docx|rtf|txt';
$config['max_size'] = '900';
$this->load->library('upload');
$this->upload->initialize($config); // MUST CALL ELSE config not loaded
if ( ! $this->upload->do_upload()) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else {
$data = array('upload_data' => $this->upload->data());
$this->load->model('translation_model');
$this->translation_model->add_orig($job, $filePath);
$this->load->view('upload_success', $data);
}
}
}
Most probable cause for this is bad mod rewrite rules. If you are using any, try disabling them and post your data again.
这篇关于代码空$ _POST& $ _FILES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!