locked
select file automatically in page load. [preset file location] RRS feed

  • Question

  • User944339287 posted

    hi guys.. i wonder is it possible to select a file automatically [preset file location]?

    Monday, May 6, 2019 8:46 AM

All replies

  • User753101303 posted

    Hi,

    You mean for an input type="file" control ? You can't for safety reason. This is a read only control so that only the user can tell which file(s) should be uploaded.

    Monday, May 6, 2019 9:35 AM
  • User283571144 posted

    Hi  kengkit,

    According to your description, I couldn't understand your requirement clearly.

    Do you mean you want to upload the default file when the page is loaded, or choose the default file to display on the page, or choose a file by default when the file is downloaded?

    If you want to select default file for input file control when the page loads, as PatriceSc says we couldn't set the default file for input fileupload.

    If this is not your requirement, please feel free to let us know.

    Best Regards,

    Brando

    Tuesday, May 7, 2019 5:47 AM
  • User-1038772411 posted

    Where is the last used directory saved?

    It is stored in the registry. The exact location depends on the Windows version, for Win7 it is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32. A quick look with regedit ought to convince you that you don't want to mess with that.

    The simple workaround is to provide a valid path. If the one you calculate isn't valid, Directory.Exists returns false, then provide a valid one. Like the Documents folder returned by Environment.GetFolderPath(). Then again, nothing wrong with the last used one either, the user will easily recognize it with good odds that it happens to be close to the desired one.

    Tuesday, May 7, 2019 12:23 PM
  • User-418973555 posted

    for which you might trying to find file path to some images/doc files, 

    try storing in Sessions, or stateless in Db then retrieve it based on userid, 

    Session only works in per session, but Db will call the file path everytime the user log in based on his/her userid,

    then during page load

    if (!IsPostBack)
    {
         'retrieve file path based on userid then assign to Session
    
    }

    Friday, May 10, 2019 5:33 AM