Hi all,
I'm trying to get dojo file upload working, but for some reason when I send the AJAX request through dojo.io.bind, the target script isn't getting the <input type="file"> information. Here's the javascript:
function uploadPicture(form) {
var bindArgs = {
url: "cp_menu_upload_pic.php",
method: "post",
error: function(type,error) {
//restore the form
//...code goes here....
result.innerHTML = error;
},
load: function(type,data,event) {
//restore the form
//.....code goes here.......
result.style.display = "block";
if (t.indexOf("error") > -1) {
//there's an error?
result.innerHTML = data;
} else {
//we're given the filename so let's grab that
dojo.byId("pic-filename").value = data;
//generate some beautiful HTML
var html = "";
result.innerHTML = data;
}
},
mimetype: "text/plain",
formNode: form
};
dojo.io.bind(bindArgs);
return false;
}
Yes, I did include dojo.require("dojo.io.IframeIO");
Here is the target script, cp_menu_upload_pic.php
print_r($_POST);
print_r($_FILES);
pretty straightforward, I'm just trying to see what I get.
Here is the form HTML:
<form id="pic-upload-form" onsubmit="return uploadPicture(this);" method="post" enctype="multipart/form-data">
<tr>
<td colspan="4">
<label for="pic-file">Upload Picture: </label>
<input type="file" name="pic-file" id="pic-file" size="30" />
</td>
</tr>
<tr>
<td colspan="3">
<input type="submit" id="pic-upload" name="pic-upload" value="Upload"/>
</td>
</tr>
<tr>
<td colspan="4">
<div id="pic-upload-result" style="display:none">
<input type="hidden" id="pic-filename" name="pic-filename" value="" />
</td>
</tr>
I feel like I'm missing something important but browsing through the internet I can't seem to pinpoint the problem.
Any ideas?
Thanks in advance!