-1

I have a form that lets users upload a image of them self. I need an jQuery event handler for when the input in uploaded.

<script>
  $('#imageFile').someeventhander(function(){do some work son!});
</script>

<input id="imageFile" type="file">
SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
JamesTBennett
  • 2,091
  • 6
  • 19
  • 22

3 Answers3

1

This is a very complex problem, as file inputs do not upload until you submit a form. See this related question:

How can I upload files asynchronously?

Community
  • 1
  • 1
Ian Henry
  • 22,255
  • 4
  • 50
  • 61
0
$('#imageFile').change I believe is what I needed.
JamesTBennett
  • 2,091
  • 6
  • 19
  • 22
0

To upload a file you need the server to accept it and send a response back to the browser. jQuery can then use the response to trigger an event or call a function. So the answer depends on how your server is handling the upload.

swfUpload is a popular solution that uses a small Flash movie the handling the uploading. There is a jQuery plugin for it that triggers numerous events that allow you to monitor start/progress/error/completion of the upload.

johans
  • 16