Reputation:
I am trying to read the file when I paste the path in text box and when I click the file read button. The problem is that it's not reading -- but for input tag with file option it is reading.
Can you guys tell me how to achieve it? Providing my code below.
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);
Upvotes: 0
Views: 68
Reputation: 121
Sorry this cannot be achieve due to security reasons.
The only way you can get the file when a user selects it by own.
Else, anybody can run some simple script from the console to upload thousands of malicious files on your app/server. That is why you need an input with a type file.
Upvotes: 3