Rev 15 | Rev 77 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// The file has JSON type.header('Content-Type: application/json');// Prepare the file name from the query string.if (!preg_match("#^[a-zA-Z0-9_]+$#", $_GET['file'])) {die;}$file = "../tmp/pb_" . $_GET['file'] . ".txt";// Make sure the file is exist.if (file_exists($file)) {// Get the content and echo it.$text = file_get_contents($file);echo $text;// Convert to JSON to read the status.$obj = json_decode($text);// If the process is finished, delete the file.if ($obj->percent == 100) {@unlink($file);}}else {echo json_encode(array("percent" => null, "message" => "File Not Found"));}