Member Avatar for LastMitch

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>
Member Avatar for cuonic

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

Hope it works ;)

commented: I appreciate that you took the time help me! +2
Member Avatar for LastMitch

@Cuonic,

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

Member Avatar for LastMitch

@Cuonic,

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.