Solved

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

Posted on 2009-07-14
6
440 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
Technology Partners: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
links not working 2 25
Html split(text) Part2 6 20
how to customize the text in the legend in highcharts 3 30
How to pass values to HTML-5 attribute dynamically? 24 44
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

713 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