gpt4 book ai didi

javascript - 如何删除未定义的路径?

转载 作者:行者123 更新时间:2023-11-28 04:46:56 24 4
gpt4 key购买 nike

我想要这个...>C:\cutoff.docx...

但结果显示如下...>C:\fakepath\cutoff.docx...

我想从中删除\fakepath\,我该怎么做...?*

HTML

<input type="file" id="fileToUpload" name="fileupload"  style="display: none" accept=".xlsx,.xls,image/*,.doc, .docx,.ppt,  .pptx,.txt,.pdf"  onChange="Handlechange()"/>

Script

<script>
function HandleBrowseClick()
{
var fileinput = document.getElementById("fileToUpload");
fileinput.click();
}

function Handlechange()
{
var fileinput = document.getElementById("fileToUpload");
var textinput = document.getElementById("filename");
textinput.value = fileinput.value;
}

</script>

最佳答案

只需执行 fileinput.value.replace('fakepath\\', '')

这是一些浏览器的安全措施,以防止 JS 知道文件在计算机上的实际位置。

此问题不会发生在后端,因为您将使用文件的实际 tmp 路径(上传时已经在您的服务器上)。

关于javascript - 如何删除未定义的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42524812/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com