kney Posted April 21, 2011 Share Posted April 21, 2011 Hi, Here's my problem: The first 5 or 10 tries it should say "file not found". After the 10th try it should automatically say "file found". BUT it should also time out after like 50 tries and it hasn't found the file. But i don't know how to do this.. I currently have this code: <?php function respond_xml($status, $message) { $out = new XMLWriter(); $out->openURI("php://output"); $out->setIndent(true); $out->startDocument("1.0", "ISO-8859-1"); $out->startElement("statuscheck"); $out->writeElement("status", $status); $out->writeElement("message", $message); $out->endElement(); $out->endDocument(); $out->flush(); } function main() { header("Content-type: text/xml"); if (!isset($_GET["file"])) respond_xml("ERROR", "File parameter missing"); else if (file_exists($_GET["file"])) respond_xml("OK", "File exists"); else respond_xml("NOT OK", "File does not exist"); } main(); ?> This code works and gives a correct XML response when you type in for example "http://localhost:8080/php/script.php?file=test" it's says: <statuscheck> <status>NOT OK</status> <message>File does not exist</message> </statuscheck> Now, I need it to be able to check it every 5 seconds so i've use this code header("Refresh: 5; URL=http://localhost:8080/php/script.php?file=test"); Quote Link to comment https://forums.phpfreaks.com/topic/234328-check-for-files/ Share on other sites More sharing options...
kney Posted April 22, 2011 Author Share Posted April 22, 2011 still no response... Quote Link to comment https://forums.phpfreaks.com/topic/234328-check-for-files/#findComment-1204763 Share on other sites More sharing options...
kney Posted April 26, 2011 Author Share Posted April 26, 2011 just to keep topic on top.. Quote Link to comment https://forums.phpfreaks.com/topic/234328-check-for-files/#findComment-1206312 Share on other sites More sharing options...
saurabhx Posted April 26, 2011 Share Posted April 26, 2011 You can set a count in a session variable when the page is first loaded and then increment it each time it reloads. Then you can check the count and decide to check for the file or show the timeout message, right? Quote Link to comment https://forums.phpfreaks.com/topic/234328-check-for-files/#findComment-1206343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.