Solved

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

Posted on 2009-07-14
6
434 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
Comment Utility
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
Comment Utility
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
Comment Utility
I was afraid of that...
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:tjgquicken
Comment Utility
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
Comment Utility
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
Comment Utility
OK, thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses how to create an extensible mechanism for linked drop downs.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now