0

Hi

I'm trying to open a file from my OS (Window 7) from my web host server. But it can't load the files. I try fget() but it seems like it's not reading it?

<?php
session_start();
header("Cache-control: private");
include("include/capable.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="css/link.css" type="text/css" rel="stylesheet">
</head>
<body>

<? include("header.php");?>

<?php
$filename="$_SERVER[DOCUMENT_ROOT]/filelinks/data.file";
if (!file_exists($filename)){ // Check for file existence
print "No such file or directory";
exit();
}
 $fh=fopen($filename,"r"); // Open the file for reading
while( !feof($fh)){
$line_of_text=fgets($fh); // Get text line from the
file
print "$line_of_text";
}
fclose($fh); // Close the file
?>

<? include("footer.php");?>

</body>
</html>
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by LastMitch
1

On line 18 change to $filename = $_SERVER[DOCUMENT_ROOT] . "/filelinks/data.file";

Hope it works ;)

Edited by cuonic

Votes + Comments
I appreciate that you took the time help me!
0

@Cuonic,

Thanks for the reply! You put a period. I will try to change it now.

2

@Cuonic,

It works! I appreciate that you took the time help me. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.