0

I have the following code:

<tr>
    <td class="labelbg">File :</td>
    <td>
        <input type="file" name="upload" id="upload"></input>
    </td>
</tr>
<tr>
    <td class="labelbg" valign="top">Remarks<sup class="required">*</sup></td>
    <td class="field">
        <textarea name="approvalremarks" cols="38" rows="4" class="field"/>
    </td>
</tr>

<td colspan="2" width="5%" align="right">
    <a href="javascript:approval()">
        <img src="/ock/images/oess_images/item_save24.png" alt="Save" border="0"/>
    </a>
</td>
</table>        
</td></tr>

I have try this code to get the fullpath of the file but it input C:\\fakepath.

How to get the correct path?

var filename = document.getElementById("upload");
alert(filename.value);
Termininja
  • 6,620
  • 12
  • 48
  • 49
Izan Ezany
  • 1
  • 1
  • 2

2 Answers2

0

JavaScript, basically, is a language running on client side and can not retrieve information above the context of your browser. For security reason, with JavaScript basically, it is not possible to get information from your System. It is a restriction.

Please read this answer to avoid System restriction https://stackoverflow.com/a/15201258/6776417

Community
  • 1
  • 1
-1

You can do something like this using Jquery.

<script>
  $(":file").change(function(){
    alert($(":file").val());
  });
</script>

Refer this answer: Get the file name after click open button in file browse dialog box using JavaScript/jQuery

Thank you

Community
  • 1
  • 1
Akshay
  • 700
  • 9
  • 23