how to send a input file type via javascript in joomla modules

Viewed 794

I want to send a file with javascript to php file .
I have this form in my php file

<form action="" method="post" enctype="multipart/form-data">
   <label for="file">Filename:</label>
   <input type="file" name="file" id="file1"><br>
   <p id="poi">upload</p>
   <p id="plo"></p>
</form>

and white this code in js file

jQuery(document).on("click","#poi",function(){
   var objfile=new FormData();
   var file=jQuery("#file1").get(0).files[0];
   objfile.append("iefile078",file);

   var ajax ;
   ajax.upload.addEventListener("progress" ,progresshandler ,false);
   function progresshandler(){
      jQuery("#plo").text("uploading ....");
   }
   ajax.open("POST","helper.php");
   ajax.send(objfile);
});

when I click on the "upload" on my page this function fired correctly.
I want to when upload is progressing "uploading .... " show to user.
additionally I want to send this file to helper.php file.
how to set attribute to the open() and send() function in this case to passing file uploaded to the helper.php?
this is my file structure and my form place in the default.php

js
    jquery.js
tmpl
    default.php
helper.php
mod_upload.php
mod_upload.xml
1 Answers
Related