Solved

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

Posted on 2009-07-14
6
439 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
  • 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 125 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
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.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery Sticky Menu 24 36
How to delete "dots" above Bootstrap 3 navbar 4 62
JQuery Syntax... 4 37
javascript - insert into js doc help 2 25
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

829 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