?
Solved

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

Posted on 2009-07-14
6
Medium Priority
?
443 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Suggested Courses

800 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