I have a table showing file location along with other informations. for eg :
When the user click on the first row ie on $_FILES
then it should display the contents of FileA.txt
. Is it possible to do this using javascript or using Angular js?
I don't want to use
<input type='file' />
as we already know the file location and also it gives dialog box which ask to save the file, I don't want this. Instead I directly want to show file content. But as I said it shows dialog box which I don't want to show hence looking for alternative.
Thanks in advance,
Ramesh
You can do this using php:
<?php
$filepath = "yourpathhere";
$content = file_get_contents($filepath);
echo $content;
?>
You need to give file location as id
of corresponding <tr>
. file_class
is class of table. and create a div with class text
in which file content will be displayed. JQuery Code is:
$(document).ready(function() {
$(".file_class").click(function() {
var file_location = $(this).attr('id');
$.ajax({
url : encodeURIComponent(file_location),
dataType: "text",
success : function (data) {
$(".text").html(data);
}
});
});
});
HTML Code should be like this:
<table class="file_class"><tr id="D:\input.txt"></tr></table>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.