Writing the full path of the file when it is browsed using php

前端 未结 8 716
小蘑菇
小蘑菇 2021-01-17 17:35

So far I wrote a script so that I can browse for a file and see the printed name of the file. Here is the script:

 
相关标签:
8条回答
  • 2021-01-17 17:46

    I did hit the same issue but not in the same circumstances. Only IE10 gave me the full path while firefox (and probably all others) doesn't. In my case, i use a server with php, so i ask the user to select the file and i upload it on the server to use it how i need. I hope it helped.

    0 讨论(0)
  • 2021-01-17 17:46

    Getting full path of client-side file to serverside is something exposing file system access of client-side. This is not allowed because there are several security reasons.

    0 讨论(0)
  • 2021-01-17 17:47

    Using JavaScript and a hidden field you can do this:

    $('#someHiddenField').val( $('#myFileField').val() );
    

    but keep in mind that not all browsers return the full path (specifically FF only returns the file name).

    0 讨论(0)
  • 2021-01-17 17:54

    You need to change the settings of your browser and then you can access the relative path of your file.

    Chrome you will get real path using this.files[0].webkitRelativePath

    FirFox you will get using this.files[0].mozFullPath

    0 讨论(0)
  • 2021-01-17 17:55

    This seems you wanting full path of your file. Kindly try to use :__FILE__

    0 讨论(0)
  • 2021-01-17 17:57

    There is no way to do it, as the display is controlled by browsers. Some browsers will display the whole path while others will only display the name of the file.

    0 讨论(0)
提交回复
热议问题