Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    File Chooser

    I would like to use the FileItem object or something similar to select a file and get the file path after it is selected it and pass it to a function. I have no need to upload anything, I would just like to expose a way for a user to select a file to be opened by a plugin.

    Is FIleItem the proper tool to use for this? If so, what event(s) can I add a listener for to extract the path (as a string if possible)?

    Additionally, can the text field that displays the value be hidden?

    Thanks,
    Last edited by ls3674; 16 Mar 2012, 14:18.

    #2
    This is fraught with peril, as attempts to access the value of a native upload control will return either nothing, just the leaf file name, or the full path. In the future, standardization is likely to lean toward exposing as little information as possible until the user actually starts the upload, especially since it's now so easy to accidentally drag and drop a file.

    Probably the safest thing is to show a hint to the user explaining a foolproof way to get to the full filesystem path in their current OS.

    Comment


      #3
      Perhaps a hidden <input type="file"> and a JSNI method to dispatch it's clicked event might work. Any thoughts?

      Comment


        #4
        Unless we're missing something about your approach, that can't work - for security reasons you can't get a value into an upload control unless the end user actually does it.

        Comment


          #5
          Perhaps I did not explain correctly, but I did mention that
          Originally posted by ls3674
          I have no need to upload anything
          . I would like to use a tool to have a user select a file (mpg or other local file) to be opened be a plugin (which can read from the local file system).

          This plugin is controlled via javascript, e.g. openFile("c:\\myfile.mpg");

          I would like to pass the function openFile(); the contents of a file chooser as a string.

          Comment


            #6
            Right - so you can't reliably get a full filesystem path from the native HTML upload control (input type="file") no matter what. This is a core limitation of the web platform.

            Options are:

            1. just encourage / guide the user to navigate to the file using normal OS methods (eg Windows Explorer) and copy/paste it's path into your app

            2. deliver a signed applet, Flash control that asks for special permissions, or similar approach that allows you out of the browser sandbox

            Comment

            Working...
            X