I m getting 413 Request Entity Too Large error while I sending my data by ajax I m getting converted base64 image encoded code...im passing that to My controller function in codeigniter..... that giving me error 413 Request Entity Too Large
$('#save-image-php').click(function() {
$.ajax({
type: "POST",
url: php_directory_save,
data: { base64_image: yourDesigner.getProductDataURL()},
success: function(data) {
if(parseInt(data) > 0) {
$( "#cart_pd" ).submit();
}
},
error: function() {
//alert('some error has occured...');
},
start: function() {
//alert('ajax has been started...');
}
});
});
public function saveimage(){
$base64_str = substr($this->input->post('base64_image'),strpos($this->input->post('base64_image'), ",")+1);
$decoded = '';
$decoded = base64_decode($base64_str);
$png_name = '';
$png_name = "product-".strtotime('now').".png";
$png_url = '';
$png_url = "uploaded_files/custom_image/".$png_name;
$id = $this->product_model->save($png_name);
$data = array('cust_id'=>$id);
$this->session->set_userdata($data);
$result = '';
$result = file_put_contents($png_url, $decoded);
if($id !=''){
header('Content-Type: application/json');
echo json_encode($id);
}
}
If you're running on nginx, this is the likely cause
In the nginx.conf
http {
server {
client_max_body_size 20M;
}
}
Increase that to a more reasonable number and do some more testing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.