So, I'm trying to make an .html file, where I can select any type of file, say .txt, or .html or .py, and have the contents of said file into a textarea on my html page. How do I go about doing this? I have no clue where to start.
            Asked
            
        
        
            Active
            
        
            Viewed 72 times
        
    1 Answers
0
            
            
        var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       console.log(xhttp.responseText);
    }
};
xhttp.open("GET", "you_file_path", true);
xhttp.send();Replace you_file_path with you link
 
    
    
        Libin Prasanth
        
- 559
- 2
- 9
- 
                    Is there a way I can use a dropdown instead of having to provide the path? – Coolsugar Apr 05 '21 at 11:24
- 
                    I'm sorry, I'm really new to javascript....how would I assign a variable to the contents of the file I called? – Coolsugar Apr 05 '21 at 11:25
- 
                    yes, you can call the API when select input changed – Libin Prasanth Apr 05 '21 at 11:25
