I've downloaded files from my svn that are now stored on a document on my local disk. Most of these files are php files. How can I read in documents (that aren't "txt") which are located on my local disk and open them on a website that uses php. So so far this is what I have,
index.php
<script>
$(function() {
$('#getData').click(function(event) {
event.preventDefault();
$.ajax({
type: "GET",
url: "endPoint.php",
data : { field2_name : $('#userInput2').val() },
beforeSend: function(){
}
, complete: function(){
}
, success: function(html){
//this will add the new comment to the `comment_part` div
$("#displayParse").html(html);
//$('[name=field1_name]').val('');
}
});
});
});
</script>
<form id="comment_form" action="endPoint.php" method="GET">
Enter the file you would like to view:
<input type="text" class="text_cmt" name="field2_name" id="userInput2"/>
<input type="submit" name="submit" value="submit" id = "getData"/>
<input type='hidden' name='parent_id' id='parent_id' value='0'/>
</form>
<div id="displayParse">
</div>
endPoint.php
<?php
$filePath = $_GET["field2_name"];
$url = "cs_data/home/" . $filePath;
$file = fopen($url, "r");
fread($file,filesize($url));
echo '<div class="comment">' . $file . '</div>';
?>
basically the user inputs a file they want to open, and the files are located on my local disk. Not sure where I'm going wrong as the file contents are not being printed out and instead I'm getting this printed out "Resource id #3". Also I am running my code on localhost using MAMP. The IDE I'm using is phpstorm. I'm not sure if my documents need to be loaded onto phpstorm in order to access them