The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Show filename of selected file

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #146590

    I have a html file input control. When user submits the form (after selecting a file), I need to show a confirmation box showing the file names and asking for confirmation.

    Here is my HTML

    Select zip file :<input type="file" class="file" name="zip_file_import" id="zip_file_import" />     
    <input type="button" value="Upload" onclick="formSubmit()" class="button-style" />

    below is the Javascript

    function formSubmit() {
                var confirm_message = confirm("Files selected for import are \n Zip File: "+document.getElementById("zip_file_import").value +"\n Manifest File: "+document.getElementById("manifest_file_import").value+" \nDo you want to proceed?");
                if (confirm_message==false) {
                  return false;
                else  {
       = "wait";

    when the alert message comes up, it show the path of the file as C:\Fakepath\

    Is it possible to get the actual file path? If not can I simply strip the file path and just show the file name?


    Here’s a function that strips the directory from the full path string:

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.