By bobzillaforever on
In my node.tpl.php file, I'm unable to get the file(s) in question to read with file_exists(), fread(), or probably any similar function. I've tried it with .txt, .flv, .pdf, .mov, .mp3, and .wmv. I've tried removing the following from my .htaccess file to no avail.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.* sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ ">
Order allow,deny
</FilesMatch>
I've also tried adding the following to my .htaccess file, which was also unsuccessful.
AddType text/plain txt
I know that the files themselves are error-free and the correct URL is being delivered.
Here's the relevant code:
$yy = date('Y', $created);
$mm = date('m', $created);
$dd = date('d', $created);
$yymmdd = $yy.$mm.$dd;
$flv = base_path() . 'files/sundays/' . $yy . '/' . $mm . '/' . $yymmdd . '.flv';
if (file_exists($flv)) {
// my code
} else {
echo '<p>file ' . $flv . ' doesn\'t exist.</p>'; }
var_dump(file_exists($test));
echo '<br />';
fread($test, 8);
The last three lines are for testing purposes. And they're failing. :-)
Any help would be greatly appreciated. Thank you!
David
Comments
A typo
It was brought to my attention that I have a nasty typo in this post. fread() refers to "$test" which I didn't post.
$test = base_path() . 'files/sundays/' . $yy . '/' . $mm . '/' . $yymmdd . '.flv';Sorry about that!
problem solved
Issue solved. I was unaware of the different ways a document root could be delivered. And unaware of how to use fread(), so my method of error-checking was faulty. My main issue was trying to get file_exists() to work.
I solved by changing:
To:
That's working for me.
To get fread() to work, I used the following code:
Thanks.