user188962
user188962

Reputation:

is it possible to do this on a input type ="file"?

I need to pass the filename of a file-input to a parent page... is this even possible?

The input type ="file" has a value, but can I use it like this?

I have used the value of the file-input to check the extension of the file, and it works! So I guess there is a value, but can this be done and is it reliable?

If not, how would you have done it?

Thanks

Upvotes: 0

Views: 132

Answers (1)

Fabien Ménager
Fabien Ménager

Reputation: 140205

You can only access the file name (without the full path) with javascript in all the browsers except IE.

var filename = document.forms.myForm.elements.myFileInput.value;

will give "file.gif" if the file c:\docs\bah\file.gif was selected

Upvotes: 2

Related Questions