Jump to content

Archived

This topic is now archived and is closed to further replies.

glenelkins

Strange file read problem

Recommended Posts

i cant see whats wrong with this?? (Warning: fread(): Length parameter must be greater than 0. in c:\program files\easyphp1-8\www\fileeditor\edit.php on line 19)
[code]
<?

// Get the file
$file = $_GET['file'];

// Check if file is empty
if (empty($file)) {
echo "Please Enter A File Name";
exit();
}

// Open the file for writing
if(!($file_handle = fopen($file,"r"))) {
echo "Cannot Read File";
exit();
}

// Read the contents of the file
$file_contents = fread($file_handle,filesize($file));

// Display The File
// In a form
?>
[/code]

Share this post


Link to post
Share on other sites
Should work if the file exists. You can use file_exists to check that.

Share this post


Link to post
Share on other sites
No worries the file being inputted into the script for some reason didnt save more than 0bytes...wierd

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.