derekm22098 Posted March 25, 2023 Share Posted March 25, 2023 Hello, I have an EXE app on my home server that uploads a .txt file (live lightning strikes) every 1 minute to my web server. Then I use this PHP code to read the text file and load it into their software (like Google Earth) where it displays it visually on the map. I'm using PHP to hide public view of strikes(us).txt file as they will scrape the data. My issue is, sometimes the software calls the PHP file which reads the .txt file and it's still being written to, not fully complete, which fails in the software. How can I use PHP to determine if this file is not open, being written to, or incomplete and either wait 2 seconds and try again or something alike. Thank you for any help. <?php header('Content-Type: text/plain'); if (preg_match('/(GRLevel2|GRLevel3|GR2Analyst)/', $_SERVER['HTTP_USER_AGENT'])) { echo file_get_contents( "Strikes(US).txt" ); } else { echo 'Please Copy & Paste the URL directly into your GRLevelX Placefile Manager!'; exit; } Quote Link to comment Share on other sites More sharing options...
requinix Posted March 26, 2023 Share Posted March 26, 2023 Short answer is there's probably no reasonable way. Upload the text file to a temporary location and then move it where you want. That way there's no partial file. Quote Link to comment 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.