Lucia
Lucia

Reputation: 4767

Detect when user has selected a file for upload (without timers)

I would like to to create a 2-step file uploader:

  1. Open dialog.
  2. Select one file from computer.

I would like to eliminate the step where the user must submit the form, and instead do it automatically with JavaScript. Is there anyway to achieve it?

Thanks.

Upvotes: 1

Views: 2424

Answers (1)

Pekka
Pekka

Reputation: 449803

Setting an onChange event and checking for whether the ".value" of the upload field is "!= null" does the trick for me. However, accessing file upload fields programmatically is always a shaky issue, and things can change with future browser security updates. If you want to be sure, use a flash based upload component like SWFUpload.

Upvotes: 2

Related Questions