繁体   English   中英

从文本框中读取文件而不在输入标签中提供文件类型

[英]Read a file from text box without giving file type in input tag

当我在文本框中粘贴路径并单击文件读取按钮时,我试图读取文件。 问题是它没有读取-但是带有文件选项的输入标签正在读取。

你们能告诉我如何实现吗? 在下面提供我的代码。

https://codepen.io/texirv/pen/dzwrqM?editors=1111

<input class="laptop" placeholder="Paste link here to upload document." type="text" name="sportsBox" id="sportsBox">

$("#swimmingLink").click(function() {
      console.log("inside click function--->" );
            playerValue = $("#sportsBox").val().replace(/\\/g,"/");
            var coffee = playerValue.substring(playerValue.lastIndexOf('/')+1)

            console.log("playerValue--->" + playerValue);
            console.log("coffee--->" + coffee);

            //var myReader: FileReader = new FileReader();
            var myReader = new FileReader();

            //var textType = /text.*/;
            var file = playerValue.files[0];
            console.log("file---->" + file);

抱歉,由于安全原因无法实现。

用户自己选择文件时,获取文件的唯一方法。

另外,任何人都可以从控制台运行一些简单的脚本,以在您的应用程序/服务器上上传数千个恶意文件。 这就是为什么需要带有类型文件的输入的原因。

暂无
暂无

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

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