Welcome Guest, Not a member yet? Register   Sign In
file upload + jquery
#1

[eluser]ibnclaudius[/eluser]
I'm trying to upload an image using jquery, but always getting the "echo 'fail';".

I'm also using JQuery Ajax Form plugin: http://jquery.malsup.com/form/

My code:

Code:
<form id="new-update-attach-image-form" method="post" action="<?php echo site_url(); ?>/form/upload_school_update_image" enctype="multipart/form-data">
   <input type="file" class="new-update-attach-image-box" accept="image/*">
  </form>

Code:
public function upload_school_update_image()
{
  $config['upload_path'] = './assets/img/school_updates/';
  $config['allowed_types'] = 'gif|jpg|png';
  
  $this->load->library('upload', $config);
  
  if ($this->upload->do_upload())
  {
   echo 'success';
  }
  else
  {
   echo 'fail';
  }
}

Code:
newUpdateAttachImageOptionsUploadBox.change(function ()
{
  newUpdateAttachImageItemName.html(newUpdateAttachImageOptionsUploadBox.val().split('\\').pop());
  newUpdateAttachImageItem.show();
  newUpdateAttachImageOptions.hide();
  
  newUpdateAttachImageForm.ajaxForm(
  {
   target: streamUpdates
  }).submit();
});



Messages In This Thread
file upload + jquery - by El Forum - 02-29-2012, 05:40 PM
file upload + jquery - by El Forum - 02-29-2012, 06:08 PM
file upload + jquery - by El Forum - 02-29-2012, 06:31 PM
file upload + jquery - by El Forum - 02-29-2012, 06:37 PM
file upload + jquery - by El Forum - 02-29-2012, 06:54 PM
file upload + jquery - by El Forum - 02-29-2012, 07:26 PM
file upload + jquery - by El Forum - 02-29-2012, 07:36 PM
file upload + jquery - by El Forum - 02-29-2012, 08:12 PM
file upload + jquery - by El Forum - 02-29-2012, 08:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB