0

I have input with <input type="file" id="logo" name="logo" ng-model="logo" required="required">. When I load page it is like:

enter image description here

When I select file:

enter image description here

How can I load the page, so that already saved file in server retrieved gets like:

enter image description here

Not this:

enter image description here

AmazingDayToday
  • 3,724
  • 14
  • 35
  • 67
  • 1
    you can't set a file path to a file input – Daniel A. White Jan 26 '18 at 02:42
  • @DanielA.White is there a workaround? – AmazingDayToday Jan 26 '18 at 02:43
  • @DanielA.White Yes, the requirement is possible, see [How to set File objects and length property at FileList object where the files are also reflected at FormData object?](https://stackoverflow.com/questions/47119426/how-to-set-file-objects-and-length-property-at-filelist-object-where-the-files-a) – guest271314 Jan 26 '18 at 02:47
  • Sounds like you are submitting the entire page. Once the page is submitted a new blank form is re-displayed. You need a way to retain the name of the file. How you do this depends upon the server-side language that you are using. –  Jan 26 '18 at 02:48
  • ..."*already saved file*"... where has been saved this file? Does your UI consist only of the original `` tag? Doesn't look so and in this case, you can probably make it say whatever you want. But for us to help you, we will need more than these images. – Kaiido Jan 26 '18 at 02:59
  • @Kaiido OP appears to be referring to the uploaded file – guest271314 Jan 26 '18 at 03:01
  • @guest271314 even this *uploaded* term is not really clear and that's why I ask clarifications: Is it one that has been *uploaded* to the server or one that has only been *selected* previously? Some browsers (e.g FF) already offers input auto-completion from soft-refresh, I feel it's what OP wants, but I am not sure. – Kaiido Jan 26 '18 at 03:11
  • @Kaiido OP should be able to piece together the `onload` portion of the inquiry, at a minimum using the code at the answers at [Persist variables between page loads](https://stackoverflow.com/questions/29986657/persist-variables-between-page-loads/30144363?s=1|38.5969#30144363). Do you consider the present Question to be a duplicate of the linked Question? – guest271314 Jan 26 '18 at 03:16
  • 1
    @guest271314 not really no. I consider this question to be unclear since we don't know what exactly is the current status of OP, nor what they are really trying to achieve. So maybe off-topic lacks MCVE could fit too. But I'll wait until they come back before VTC, to give them a chance of clarifying. And note that if jeff's comment is right, then it's absolutely not a dupe since all they would need would be to make an ajax request with a FormData. – Kaiido Jan 26 '18 at 03:21
  • @Kaiido, you are right. This is to grab the file uploaded to server before. So that I refresh and get back the file if there and display the name. If not, then it should be "No file chosen". Hence, if file exists, then "img3.png" instead of "No file chosen". – AmazingDayToday Jan 26 '18 at 19:13

0 Answers0