Welcome Guest, Not a member yet? Register   Sign In
Using xajax, get File POST variable for Upload
#1

[eluser]coldfire82[/eluser]
Hi,

I have a html form with File fields in it to browse/upload the file. I call this form via xajax in a div.

Now, what I need is to get the $_FILE variable values in javascript/CI code behind.


e.g. my html form (dummy, ignore any problem with it.)
Code:
<form>
<input type='file' id='file1'/>
<input type='image' id='userimg1'>
</form>

in JS

Code:
function upload_iamge(){
// get userimg1  value();

xajax_upload_image(some_userimg1_value);
}

my xajax registered function in .php file

Code:
funciton upload_image(file_variable){
// the same objresponse.
//get file upload variable and upload to a directory.

//here, i have to get values for the below FILE variables like,
$name      = $_FILES['userimg1']['name'];
$temp_name = $_FILES['userimg1']['tmp_name'];
$size      = $_FILES['userimg1']['size'];


// and then return back the success/fail message in a div
}


Has anyone done file upload with xajax and CI ? If yes, then help please


Thanks.
#2

[eluser]Oskar Smith[/eluser]
Hello, I'm not familiar with xajax but just to check that you're aware that file uploads can't be done with javascript/ajax (XMLHttpRequest)? I'm pretty sure it's a security restriction, so instead you have to "fake it" with Flash etc.

There's lots of options on a Google search. Here's a thread about it:

http://stackoverflow.com/questions/16622...ith-jquery




Theme © iAndrew 2016 - Forum software by © MyBB