[eluser]jdfwarrior[/eluser]
[quote author="Christoffer" date="1250510444"]Hey,
I want to dynamically send an upload form to CI via jQuery. The form needs to contain the file to be uploaded and the path to save to.
So far my AJAX-call looks like this:
Code:
[removed]
file = $('#file').val();
path = active_dir;
upload_file( file, path );
function upload_file(file, path) {
$.post("/upload_file/", { file: file, path: path }, function(data) {
notice(data);
});
}[removed]
The PHP-side of the script is tested and OK. And the path is processed as it should. But I get an error message from PHP that says that 'No file was selected.'.
How should I fetch the file data from the form?
Thank you,
Christoffer[/quote]
I was playing around with the uploader class earlier this morning and ran into the same issue. My problem was though, if you check the documentation on the uploader class, you'll see that by default, the uploader class is expecting a field named 'userfile'. From your code, it appears that your file browser field is named "file" and you are also passing it as "file". If you are doing this, check to make sure that in your uploader code, that you are specifying that it should look for the "file" field. You pass that to the do_upload function. Check the documentation on it. I would bet that's your problem. I didn't notice it at first either.