Welcome Guest, Not a member yet? Register   Sign In
Question about uploading pics and jquery
#1

[eluser]joeizang[/eluser]
hey guys,

it's been a great adventure learning and using CI and I am saying this honestly the forum is almost the best I have ever used.
Anyway enof talk, I have a question like the title of this post says.

I have a form that pictures for an intranet application get uploaded through. the question is this: do I need to serialize the data from the upload form since I am using ajax with jquery? before I did the ajax thing the form would upload fine but take me away from the upload page. now the error message shows up on the same page with the form like I want it but no picture is uploaded. Below is my jquery code:

[removed]

$.ajax({
url: 'upload_picture',
type: 'POST',
data: $('#uploadpics').serialize(),
beforeSend: function(){
$('#aika').append('<p>Uploading...<img src="../images/ajax-loader.gif"/></p>').show('slow');
},
success: function(data){
window.setTimeout(function(){
$('#aika').empty();
if(parseFloat(data)){
$('#aika').append(data);
} else {
$('#aika').html(data);
}
},2000);
}

[removed]

thanks guys and God bless.
#2

[eluser]bretticus[/eluser]
Not so much a CI question really but alot of jquery users around here Wink

Disclaimer: I've never tried this but I doubt you can use $.ajax to upload a file.
I believe you need a jquery plugin to handle the multipart/form-data encode type. SOme googling indicates that there's a form plugin for this.
#3

[eluser]joeizang[/eluser]
thanks bretticus,

your answer already has put some ideas in my head. will try what I can and see. I don't feel comfortable using form plugins with jquery but I will look into it and see.
Thanks Bro.




Theme © iAndrew 2016 - Forum software by © MyBB