Writing the full path of the file when it is brows

2020-04-02 18:25发布

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:

 <form action="upload.php" method="post" enctype="multipart/form-  data">
 Select: 
 <input type="file" name="fileToUpload" id="fileToUpload">
 </form>

When I hit the browse button and choose a file, only the name of the file gets printed on my web page (My web-browser is Firefox and I am using a local server). Is there a way to print the whole address of the file? What I have found on the web so far were mostly suggesting ways when we know in advance "/path/to/file". But how can it be done if I randomly choose a file? If there is no way to do it with PHP because of security issues according to:

How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?,

Is it possible t do it with C, C++, html, etc?

I really need to show the local path of the directory. What are the alternatives? The answer is it can't be done? I found this website http://www.htaccesstools.com/articles/full-path-to-file-using-php/

Don't know how it works though.

The other alternative would be to define a fixed path and let the user only choose that directory and since it is known I can print it out. Does it make sense?

8条回答
叼着烟拽天下
2楼-- · 2020-04-02 18:50

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.

查看更多
我想做一个坏孩纸
3楼-- · 2020-04-02 18:55

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.

查看更多
登录 后发表回答