0

I have to upload a file in my project. But when I cancel the dialog box, the previously uploaded file is disappearing. Is there a way to maintain the first chosen file even after I cancel the dialog box.

Here's my code

<div class="input-field" id="uploadAuditReport">
    <label class="active">Upload Audit Report *</label>
    <input type="file" id="reportFileData" name="reportFileData" required-error="Please upload a file" class="m-b-10 card-panel" style="bottom-border: dotted 1px" pattern="^.*(xls|xlsx|doc|pdf|docx|ods|jpg|jpeg|png|XLS|XLSX|DOC|PDF|DOCX|ODS|JPG|JPEG|PNG)$" pattern-error="File must be in xls, xlsx, doc, pdf, docx, ods, jpg/ jpeg, and png format" required="" filesize="30000000" filesize-error="File must not exceed a file size of 30 MB." >                                      
</div>
doelleri
  • 19,232
  • 5
  • 61
  • 65
newbie
  • 119
  • 15

1 Answers1

1

Unfortunately, this is not possible. See: input type="file", clearing file after clicking cancel in chrome

  • you can't detect when cancel is clicked
  • you can't do anything about it
  • different browsers handle it in different ways
doelleri
  • 19,232
  • 5
  • 61
  • 65
Daniel
  • 3,312
  • 1
  • 14
  • 31