I'm want to read a simple string from a text file which is around 3-4 mb but fopen() fails ("can't open file" from die() is called). Here's the code:
clearstatcache();
$fh = fopen("/my/path/to/file.txt", "r") or die("can't open file");
$sql = fread($fh,filesize("/my/path/to/file.txt"));
Have you firstly checked to see if the file exists?
if (!file_exists("/my/path/to/file.txt") {
die('File does not exist');
}
clearstatcache();
$fh = fopen("/my/path/to/file.txt", "r") or die("can't open file");
$sql = fread($fh,filesize("/my/path/to/file.txt"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With