I am currently working on building an AJAX file upload module. Below is a snippet of the code I have been using:
//creating a form for uploading files via AJAX
FileUploader.prototype.createForm = function() {
// creating a new form
var form = document.createElement('form');
form.id = this.form_id;
form.action = this.url;
form.method = 'post';
form.enctype = 'multipart/form-data';
form.target = 'file_upload_iframe';
// attempting to create a file input failed at [1]
/* var input_file = document.createElement('input');
input_file.type = 'file';
input_file.name = this.name;
input_file.value = this.file; [1] */
// attempting to clone the input file, but failing to insert it into either the old form[2]
// or the new form [3]
var input_file = document.getElementById('userfile');
var new_input_file = document.cloneNode(true);
// document.getElementById('file_upload').appendChild(new_input_file); [2]
new_input_file.id = '';
form.appendChild(new_input_file); // [3]
document.body.appendChild(form);
return form;
};
Can you explain why I am encountering a security error
Security error" code: "1000
at point [1]? Do you know where I can find more information about this issue?What could be the reason for not being able to append the new_input_file to the newly created form[3] or even appending the cloned new_input_file to the old form([2])?
Thank you.