The filemtime () isn't working for my script, but is working fine for the script where I copied the example code

Multi tool use
Multi tool use


The filemtime () isn't working for my script, but is working fine for the script where I copied the example code



I have a .txt file located under some folder of my data files. Now I have created a long polling system (actually copied the code ) which is run by ajax.
Now the problem is that my php script is unable to fetch file modification time of the text file (it totally disregards the file).



Below I have both the original code of the author and my twerked code. The one of the author worked fine, but not mine.
Plz help.



The apache server is hosted on windows server



THe file path is absolutly correct and file exist.



Here's the section of my code which has error


while (true) {
//**The error occurs here**
$fileModifyTime = filectime($file);

if ($fileModifyTime === false) {
throw new Exception('Could not read last modification time');
}

// if the last modification time of the file is greater than the last update sent to the browser...
if ($fileModifyTime > $lastUpdate) {
setcookie('lastUpdate', $fileModifyTime);

require 'msgread.php';
// get file contents from last lines...
$fileRead = tailCustom($file, 8);

exit(json_encode([
'status' => true,
'time' => $fileModifyTime,
'content' => $fileRead
]));

}

// to clear cache
clearstatcache();

// to sleep
sleep(1);

}



here's the original code from where i copied
the author's original polling code



and here's my full code, just in case needed
My script which has error





You cannot directly link to PHP files unless you disable the interpreter for that directory. Please also add information about your OS (and the OS of the server).
– DBX12
Jul 2 at 6:40






😀 sorry for that mistake of mine, i just hosted it on mirror site .
– Aman Kumar
Jul 2 at 6:43





@AmanKumar I'm on a mobile device so I can't help you unless you put the file on the page; my iPear refuses to open the file.
– wizzwizz4
Jul 2 at 6:45





Oh! I am also on mobile device.
– Aman Kumar
Jul 2 at 6:46





Okay, just wait a second , I am trying
– Aman Kumar
Jul 2 at 6:46




1 Answer
1



I suspect that your problem is that file.txt does not exist. have you created it and ensured that it's in the current working directory of the script?


file.txt



It's impossible to say more without seeing your actual code. If you select it and press Ctrl + K that will indent it all.





sorry for poorly arranged question. i have edited them, plz have a look
– Aman Kumar
Jul 2 at 7:01







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

lSwTo 4b T45Zd 6jz5RxcNNMp8wzg5JWyXPHz3hh,s,z c84UfV4Wwdhc80zV3V30 TCRjJu88L
TCxU,gYLIZQCOaU6Cl,NHLh f3JF93na2Irc1MQET,AY

Popular posts from this blog

Rothschild family

Cinema of Italy