I tested your latest if conditions and all work for me as expected.
Have you checked what is the condition what fails?
The common reasons I could think of are:
- filename is wrong, eg no extension
- file path is wrong
- no read permissions on the file
I used the following code to test what condition fail:
$hash = 'test1';
echo '<br>Testing file '.__DIR__."/uploads/json_".$hash.'<br>';
if(
file_exists(__DIR__."/uploads/json_".$hash) &&
(filesize(__DIR__."/uploads/json_".$hash) > 100) &&
(time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600)
){
echo 'true';
} else {
echo 'false';
}
echo file_exists(__DIR__."/uploads/json_".$hash)?"<br>File exist":"File not exists ";
echo filesize(__DIR__."/uploads/json_".$hash) > 100?'<br>Size ok':'<br>Size wrong';
echo time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600? '<br>Time ok':'<br>Time wrong';