Welcome Guest, Not a member yet? Register   Sign In
Upload file using ajax...
#11

[eluser]munnu[/eluser]
i have also try to upload file but it gives me an error "You did not select a file to upload"
what is the problem it could be

[removed]
jQuery(document).ready(function(){
//alert('load');
jQuery('.upload').change(function(){
//jQuery('#graduate').removeAttr('action');
alert(this.name);
ajaxFileUpload(this.name);

});
});
function ajaxFileUpload(file_obj){
alert("<?php print site_url('upload/do_upload')?>");
alert(file_obj);
jQuery("#loading")
.ajaxStart(function(){
jQuery(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});

jQuery.ajaxFileUpload
(
{
url:'<?php print site_url('upload/do_upload')?>',
secureuri:false,
fileElementId:file_obj,
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.msg);
}
}
},
error: function (data, status, e)
{
alert(e);
}
}
)

return false;

}
[removed]

//upload file
<?php
$application_essay=array(
'id'=>'application_essay',
'name'=>'application_essay',
'class'=>'upload'
);
print form_upload($application_essay);
?>
#12

[eluser]oldroy[/eluser]
Munnu:

The file not chosen thing is likely because you are not passing a $field or the correct $field to the upload object. You'll need to use either $this->upload->do_upload('upload') or ('uploadfile').....Check the Upload library and you will see what I'm talking about. I had the same problem and then I did print_r on my $_FILES array and found that on my uploads to my ubuntu/apache/php box my $_FILES['upload'] that I was used to on uploads was actually $_FILES['uploadfile'].
So on my uploads from extjs upload forms I use $this->upload->do_upload('uploadfile') and all is well and works.

I don't know the inner workings of JQuery.ajaxFileUpload so you may want to see the values of your post and in firebug.

Hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB