4614

Accessing input type=“file” full path from a Java applet

Question:

It is possible to access HTML DOM from an applet using netscape.javascript JSObject API. However, if I query a value of a input type="file", on some browsers (Opera) I get a full path to a selected file, but on other browsers (Firefox, Chrome) just a file name <em>without path</em>.

Is it possible, having an HTML input type="file", to figure out the full path to the file selected in it from a Java applet?

The reason why I bother: signed applets can access file system, and browsers' file selectors are a lot nicer than Java swing one.

Answer1:

You cannot. You're restricted by HTML/JS (and browser) security limitations. Officially, the value of input type="file" should only return the filename, never the filepath. I am however surprised that Opera returns the full path, namely because MSIE was the only one I knew of who did it.

But as you're already running an applet, why don't you just make use of its capabilities? You can use <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html" rel="nofollow">Swing's JFileChooser</a> to select a file, exactly as you can do with HTML input type="file".

Recommend

  • Cast or convert DD-MON-YYYY AM/PM to YYYY-MM-DD
  • Gulp watch not watching file changes
  • Message ordering in socket.io
  • Disable then re-enable click function jQuery
  • why does my android spinner display the radio button in the textview?
  • How to Backup and Restore a MySQL Database using NetBeans?
  • iOS 11 on NavigationBar pull down - height of bar changes?
  • Access sharepoint list from web site hosted externally from sharepoint
  • Angular Custom Order Pipe sorting array correctly
  • Substatemachine
  • How to use a string like a variable in Visual Basic
  • Make Friend the constructor of a template class
  • 128 bit string to array using boost::spirit::*
  • why can't I use reflection to take the address of a slice?
  • Eclipse (ctrl+space) content assist hook
  • isotope shakes after the transition
  • EditText doesn't start automatically
  • Spring Security OAuth 2 with form login
  • ODBC connection to an .accdb file
  • Why is this Animatable property being set again?
  • Migrating MOSS 2007 from SQL 2000 to SQL 2005 [closed]
  • Newtonsoft.json serializing and deserializing base/inheirited where classes are from shared projects
  • using vtkTimerCallback with QVTKRenderWindowInteractor not working
  • How to use CoreFoundation in QuickTime SDK for Windows?
  • Finding all XML nodes between each two processing instructions
  • React/Redux. Access state from other component
  • How to add ng-app after page load?
  • async GET request with body from browser
  • Align microsoft access queries
  • Use 2D Text into 3D scenes in JavaFX results in blurry texts
  • can you use embedded ruby in custom javascript files in rails?
  • Auto send email based on the time and email address in database
  • Scripting Support For Image Filtering in DigitalMicrograph
  • Adding horizontal slider to QTableWidget
  • Javascript inside HTML import not affecting imported HTML
  • C# code can't “see” the methods in my C++ dll
  • JavaMail connection problems [duplicate]
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Create an average of multiple excel chart without the data source
  • JavaScript RegExp Replace