Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get the complete path from an HTML file input control?

Posted on 2009-07-14
6
Medium Priority
?
444 Views
Last Modified: 2012-05-07
Is there any way for me to get the directory and filename from an HTML file input control. It looks like document.getElementById['fileInput'].value only retrieves the filename, but I what I want to do is pass the file to a Java applet that will scan the entire directory for files with the same name (but different extensions) and zip them all into a single file. Thanks.
0
Comment
Question by:tjgquicken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24856802
I dont think i got your question completely.

 <form enctype="multipart/form-data">
  <input type="file" id="fileId"/>
  <input type="button" onclick="alert(document.getElementById('fileId').value);" value="Show Value"/>
  </form>

using the above code would give u the complete path for the file selected.  In order to get the file you need to use Oreilly Multipart request or Commons File upload to get the file contents loaded.

-Murali*
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 24856984
tjgquicken,

Javascript won't give you the full path.  The browser prevents clientside script from providing this.  If you have a a Java applet that is part of this page you will need to have it provide the file input field too.  Then you can get the path.  The browser and a normal input (file type) won't provide it to you.  There may be exceptions in older browsers but those are a few editions old by now and would not be reliable for a current site.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:tjgquicken
ID: 24870340
I was afraid of that...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tjgquicken
ID: 24880336
Looks like I might have closed this question too soon... Does anybody know what will happen if I run a signed Javascript app -- will that let me capture the entire path and filename?
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24882499
It would not.  Signed or unsigned the browser doesn't let the clientside script get that info.  Only a couple of older versions did, if I remember right, but that was considered a security flaw and corrected so no current one should.  Signing the script should not make a difference at all though.
A signed applet or ActiveX object would be a different thing though.  They would be worth signing so the browser would trust them more.
bol
0
 

Author Comment

by:tjgquicken
ID: 24882545
OK, thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question