Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 16th Mar 2012, 14:15
ls3674 ls3674 is offline
Registered Developer
 
Join Date: Sep 2011
Posts: 129
Default 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; 16th Mar 2012 at 14:18..
Reply With Quote
  #2  
Old 19th Mar 2012, 13:45
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

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.
Reply With Quote
  #3  
Old 19th Mar 2012, 14:59
ls3674 ls3674 is offline
Registered Developer
 
Join Date: Sep 2011
Posts: 129
Default

Perhaps a hidden <input type="file"> and a JSNI method to dispatch it's clicked event might work. Any thoughts?
Reply With Quote
  #4  
Old 19th Mar 2012, 15:03
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

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.
Reply With Quote
  #5  
Old 19th Mar 2012, 15:07
ls3674 ls3674 is offline
Registered Developer
 
Join Date: Sep 2011
Posts: 129
Default

Perhaps I did not explain correctly, but I did mention that
Quote:
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.
Reply With Quote
  #6  
Old 19th Mar 2012, 15:14
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,524
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Builder hanging p27939 Installation 11 7th Mar 2012 11:08
Launching Visual Builder in samples RevMen Smart GWT Technical Q&A 10 9th Sep 2011 10:05
UploadItem: how to configure the file chooser jpaumard Smart GWT Technical Q&A 0 29th Mar 2011 09:43
FileDownload question acarur01 Technical Q&A 11 18th Mar 2010 13:33
UploadItem marked as required in a DynamicForm Nick Mogielnicki Technical Q&A 7 16th Dec 2009 06:57

© 2010,2011 Isomorphic Software. All Rights Reserved