Event button Fileupload with Submit Gmail style

Asked

Viewed 381 times

3

I’m using vb.net and asp.net with forms And I need to add an event that by clicking on the select button a file to attach, when I select the file it automatically save, without having another button to give the Submit. Style of gmail. Someone could give me a light?

  • What have you tried?

  • At first I tested several things but deleted excluding... The Vb code of the button is here: "<div> <Asp:Label ID="Label2" runat="server">File:</Asp:Label>" "<Asp:Fileupload ID="fuArchive" runat="server" Width="400px" Enabled="true" Cssclass="upload"/> </div>"

  • I got it . . .

2 answers

1

jQuery uploadify plugin will load with a progress bar, and includes functionality for uploading single or multiple files.

  • 1

    So my dear, I’m not using php but Vb.net, how could I in my Vb code add jquery? The Vb code of the button is here: "<div> <Asp:Label ID="Label2" runat="server">File:</Asp:Label>" "<Asp:Fileupload ID="fuArchive" runat="server" Width="400px" Enabled="true" Cssclass="upload"/> </div>"

  • the idea is the same, just change your backend

  • 1

    @durtto add an example of how the plugin works and how it can apply to the OP case to improve the response.

0

You can use the event change, in javascript. Then you send the form when the file input triggers this event. Example:

file = document.getElementById("file");
form = document.getElementById("form");

file.addEventListener('change', function(){ //quando o input de arquivo mudar...
	form.submit();                          //...o form é enviado
})
<form enctype="multipart/form-data"
      method="post"
      action="seu_script.php"
      id="form">
  <input type="file" name="arquivo" id="file" />      
</form>

Inside the stack overflow will not work because it prevents form Submit, but you can see it working on: http://jsfiddle.net/Lpppdfwm

Browser other questions tagged

You are not signed in. Login or sign up in order to post.