The question was presented to my mind, y cant you use ajax to upload files and I got the answer no. However now Ive seen it done in pages.google.com. (Well maybe not using ajax but atleast some javascript magic) Originally I thought ok maybe it could be done by creating a form element dynamically and then attaching a file input element to it with value = to the file that user selects in a similar element rendered on screen.
While you can get this value from a file input, it seems you cant set it, as an example you cannot do this:
something about the value filed of a file input being read only. Any other solutions ppl? Bear in mind that javascript has no access to the file system. Well as far as I know.Code:<html> <head> <script type="text/javascript"> window.onload = function() { var upload_input = document.getElementById('upload_input'); var upload_form = document.getElementById('upload_form'); var upload_form_file = document.getElementById('upload_form_file'); upload_input.onchange = function(){ // echo file selected alert(this.value); // echo null alert(upload_form_file.value); // does not work! upload_form_file.value = this.value; } } </script> </head> <body> <form> <input type="file" id="upload_input" /> </form> <div> <form id='upload_form' action='upload.php'> <input type="file" id="upload_form_file" /> </form> </div> </body> </html>