0

I have an app that is used in house only that uploads the same file from the same folder every morning. There is no chance that the file name or location will change.

Using #file name="" opens the folder where the file is located. That allows the user to select the file.
I need to "hard code the file path into the input so the same file is always uploaded. Any suggestions? Thanks

<input type="file" #file name="fileLocation" (change)="onFileChange($event)" />

headmelon
  • 83
  • 1
  • 6
  • Possible duplicate of [How to open a file browser with default directory in Javascript?](https://stackoverflow.com/questions/17420595/how-to-open-a-file-browser-with-default-directory-in-javascript) – sabithpocker Jun 20 '19 at 14:44
  • 2
    Shouldn't you schedule a daily task on the server to do that? Maybe with a script or a batch file. – ConnorsFan Jun 20 '19 at 15:20

1 Answers1

1

From what ive read, it is impossible. Reading from disk without user input is not allowed in javascript.

look here

The only thing I can think of is to save the file in your assets folder , then load it using the file reader and append it to a FormData object. Overwise upload it to a file server, but that will defeat the purpose of uploading it everyday.

Jensen
  • 6,615
  • 1
  • 10
  • 12