我可以通过ajax发送数据,但服务器返回错误:500 POST sing_in。
我认为问题是配置:
$config["upload_path"] = './uploaded_files';
但不是。
你认为这里的问题是什么,因为我什么都不知道!
控制器:
public function sing_in(){
echo $_FILES['foto_user']['name'];
$config["upload_path"] = './uploaded_files';
$config["allowed_types"] = 'gif|jpg|png';
$this->load->library("upload",$config);
if($this->upload->do_upload('foto_user')){
echo "upload";
}else{
echo $this->upload->display_errors();
}
}
使用Javascript:
$(document).ready(function(){
var url ='<?php echo base_url()."index.php/inicio/sing_in";?>';
$('#sing_form').on("submit",function(e){
e.preventDefault();
//console.log("submited");
$.ajax({
url: url,
method: "POST",
data: new FormData(this),
contentType: false,
cache:false,
processData: false,
success: function(data){
console.log(data);
},error:function(data){
console.log(data)
}
});
});
});
我的观点:
/**
*TABLE SING IN
**/
$this->table->set_heading("","Sing in");
$this->table->add_row(form_label("Username: "),form_input('name_user'));
$this->table->add_row(form_label("Password: "),form_password("password_user"));
$this->table->add_row(form_label("Repeat Password: "),form_password("rpassword_user"));
$this->table->add_row(form_label("Department"),generate_dropdown("department",$departments_results));
$this->table->add_row(form_label('Foto'),form_upload("foto_user"));
$this->table->add_row("",form_submit("sing_in","Sing in"));
echo '<div id="container_table_sign">';
echo form_open_multipart("",'id="sing_form"','name="sing_form"','method="POST"');
echo $this->table->generate();
echo '</div>';