Problem with codeigniter image resizing and ajax / json. Please help! -
i have problem driving me crazy. building cms system involves uploading images jquery ajax plugin (uploadify) , having them resized server-side according user-specified dimensions using codeigntier's image resize class.
the problem (about 1 in 7 times) image resizing fails on 1 of images (up 5 images sent @ time) causing ajax post function timeout. ci's error logs says 1 of files corrupt. not quite sure how or why happens, anyway- trying set error system whereby if happens, error sent through json alerted javascript, asking them please try again or whatever. here problem-
in model have:
foreach($size_image $si){ if(!$this->resize_image($si['dimensions'],$si['filename'],$si['oldpath'],$si['newpath'])){ return false; // can confirm indeed return false whenever image resize problem occurs... } }
in controller have:
function save_page(){ if($this->admin_model->save_page()){ $return_array['error'] = ''; }else{ $return_array['error'] = 'sorry, there problem processing 1 of images.'; } $return_array['success'] = true; echo json_encode($return_array); exit(); }
whenever resizing works (and save_page function returns true) echo json encode works fine , being received @ other end , handled javascript. not when returns false!!
just prove not being silly, can replace if($this->admin_model->save_page()){ if(!$this->admin_model->save_page()){ (meaning error message when resizing does work) - , yes, error message on screen!
so whenever resizing problem occurs, reason above function refuses echo json, though getting part of script.
and absolute clarity, can this:
function save_page(){ if($this->admin_model->save_page()){ $return_array['error'] = ''; }else{ // $return_array['error'] = 'sorry, there problem processing 1 of images.'; $this->load->helper('file'); write_file('testoutput.txt','error!!!!'); // <-- , yep, 'error' written file. exit(); } $return_array['success'] = true; echo json_encode($return_array); // <-- ...so why hell doesn't work then? exit(); }
why oh why oh why?
any or suggestions welcome, many in advance.
maybe because return
$return_array['success'] = true;
every time, if fails?
Comments
Post a Comment