Set default location for document filename

When I click select for a document filename field, I want it to look and open a specified directory for that file. Further, I want to be able to dynamically set the directory where it is looking.

For example, I have radio buttons 2020 and 2021. If I click 2021, it would change my retrieval directory to c:\raw\2021. Of course if I choose 2020 radio button and click select on my doc filename field it should look in c:\raw\2020. My default document path for this form is c:\raw. Where/how do I accomplish this?

Anyone? Is there any way to specify where document filename select LOOKS for the file? Any way to dynamically change where it looks?

you can use {field_name} variables in the path

e.g. c:\raw\{year_field_name}

And you put the path…where? This is NOT where I want it to copy files…it is where I want it to LOOK on the server for the file in the first place.

I’m not sure we are talking about the same thing.

In case we are, I usually put it in the “Subdirectory for local storage” setting of the field.

Eg.

I have the root path in the Application\Settings\Documents Path as “/var/www/html/app/_lib/file/doc/”

Then in the “Subdirectory for local storage” setting of the document filename field I add “/invoices/{id}”

If the id field of a record contains “148”, the document will be saved to (when uploaded) and read from (when downloaded) “/var/www/html/app/_lib/file/doc/invoices/148”

But maybe it would work the same if you put everything int the app Documents Path setting
eg. “/var/www/html/app/_lib/file/doc/invoices/{id}” if all file fields in the same app use that same variable root path

My application\settings\documents path is set to c:\raw. But when I click select, it opens the last directory I actually used whether c:\raw\2021 or e:\somethingelseentirely. It totally ignores any hint of where to find the document in the first place.

If by “it opens” you mean the browser, afaik where it opens it is something managed on the browser and it cannot be forced by a web site.

The settings in SC are server side: where it will store/retrieve the files uploaded/downloaded

Exactly. The file I am selecting is ON the server…it is not on the client. It’s not the standard upload. I simply want it to get the file names and it really won’t upload anything.

I’m stil not following you.

Are we talking about the “Select file” button that is displayed alongside fields of type “Document (File Name)” in forms apps when adding\editing records?

If so, that is used to upload files from the browser to the web server and the process is:

  • when that button is clicked on by a user, the browser will open a file selector dialog

    • note1: no way to force, web server-side, which directory the browser will open initially in the dialog
    • note2: if from the file selector dialog the user has access directly to the web server file system where the file will be uploaded ('cause it’s network mapped on the client where the browser is run from or 'cause the client and the web server are running on the same machine) and the user select a file that is alread on the server, the end risult will be:
      • if the selected file is in a server local path different than the one configured in SC, the file will be read by the browser from the source dir and copied (via the http/https upload) to the SC configured path
      • if the selected file is in the same server local path than the one configured in SC, same as above but with an overwrite issue since source and destination dir are the same on the server: there’s an option in SC to not overwrite existing files or to increment the filename.
  • once the user select a file, it will be uploaded via http\https by the browser to the web server; the server will store it in its local path defined by the combination of the two settings (app setting + field specific setting) I described above. If those settings contain variables, they will be resolved by the server to the actual server path. Only the filename will be saved in the database field.

What are you trying to accomplish differently?

If you want to use the “Select file” button to only “tell” the server where the files are, without actually uploading them since they are already on the server (see note2 above), I don’t think that’s possible.

Yes, that is exactly what I am trying to do. When I click select file, a user should not have to navigate all over the place to find the file to upload! I want(ed) to be able to select the location for select file to LOOK . It’s odd that is not possible. I will have to abandon using that method and write something out manually to do a directory search in a specified directory. Thanks for your patience!