简体   繁体   English

将文件上传到网站时,网站是否可以查看其上传的文件路径?

[英]When a file is uploaded to a website, can the website see the file path it's uploaded from?

When uploading a file, before pressing the upload button, the folder/file path is visible in the website's upload form. 上传文件时,在按下上传按钮之前,文件夹/文件路径在网站的上传表单中可见。

上传表格 .

Is the website able to record that data? 该网站是否能够记录该数据?

Normally a website could possibly record any data typed into a web form - is this any different? 通常情况下,网站可能会记录输入网络表单的任何数据 - 这有什么不同吗?

It doesn't appear to work. 它似乎不起作用。 I created the following fiddle https://jsfiddle.net/5samkn5a/ 我创建了以下小提琴https://jsfiddle.net/5samkn5a/

Basically I took an input 基本上我接受了一个输入

<input type="file" id="input"/>

And set a listener to its value 并设置一个监听器的值

$(function(){
$("#input").change(function(){
console.log($(this).val());
})
})

Then I tried it in the latest chrome/firefox/edge They all give a fake path as value. 然后我在最新的chrome / firefox / edge中尝试了它们都给出了一条假路径作为价值。 The only thing that's real is the file name. 唯一真实的是文件名。 May be that some browsers actually expose the full path, but not the ones I tested. 可能是某些浏览器实际暴露了完整路径,但不是我测试过的路径。

It makes sense that the browser is shielding this information since at least on windows when you are choosing a document it will most likely reside in your current user directory. 浏览器屏蔽此信息是有道理的,因为至少在Windows上选择文档时,它很可能位于当前用户目录中。 So the path will contain your local user name and that's not something you want to give to a random website, right? 因此,路径将包含您的本地用户名,这不是您想要给随机网站的东西,对吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM