Last active
July 3, 2018 13:38
-
-
Save fernandoc1/b45cd46f17ef5a67457b4529a2fd474b to your computer and use it in GitHub Desktop.
A way to load files using PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $filepath = $_GET["path"]; | |
| $type = mime_content_type($filepath); | |
| header('Content-Type: ' . $type); | |
| echo file_get_contents($filepath); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <input id="filepathInput" type="text"></input> | |
| <button id="getButton" onclick="getData()">GET</button> | |
| <pre id="outputPre"></pre> | |
| </body> | |
| </html> | |
| <script> | |
| function getData() | |
| { | |
| var path = document.getElementById("filepathInput").value; | |
| fetch("get_file.php?path="+path) | |
| .then(function(response) | |
| { | |
| return response.text(); | |
| }) | |
| .then(function(text) | |
| { | |
| document.getElementById("outputPre").innerHTML = text; | |
| }); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment