I have this HTML:
<script type="text/javascript">
function uploadDone(response) {
alert(response);
}
function init() {
document.getElementById('file_upload_form').onsubmit=function() {
document.getElementById('file_upload_form').target = 'upload_target'; //'upload_target' is the name of the iframe
document.getElementById("upload_target").onload = uploadDone(response);
}
}
</script>
<form method="get" id="file_upload_form" enctype="multipart/form-data" action="../includes/parsecsv.ajax.php" target="upload_target">
<label class="uploadClick">
<button class="normal">Click to Upload Sign Ups CSV</button>
<input type="file" id="uploadSignups file" name="file">
</label>
<span class="uploadDrag"><span>or</span>Drag Your Sign Ups CSV Here</span>
<button type="submit" name="action">hello</button>
<iframe id="upload_target" name="upload_target" src="" style="width:0px; height:0px; border:none;"></iframe>
</form>
It is supposed to, when you click the submit button, upload the selected file in the file input ajaxically through an <iframe>
. I seem to have been able to get it to do the uploading, but it does not seem to run uploadDone()
when the uploading is complete? Any ideas what is wrong with it?