Rev 15 | 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.
$file = str_replace(".", "", $_GET['file']);
$file = "../tmp/pb_" . $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"));
}