0

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

1
  • what do you mean by "parent page" ? Commented Nov 12, 2009 at 20:43

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

Indeed just the usual way. I would only add: You can access it, but not edit it. Keep it in mind.
By the way, what would I do in IE then? is there a way around it?
In IE, you can access the full path ;)
FYI You can get the full path in FF < v3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.