Subversion Repositories cheapmusic

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 - 1
<?php
2
// The file has JSON type.
3
header('Content-Type: application/json');
4
 
5
// Prepare the file name from the query string.
6
$file = str_replace(".", "", $_GET['file']);
7
$file = "../tmp/pb_" . $file . ".txt";
8
 
9
// Make sure the file is exist.
10
if (file_exists($file)) {
11
  // Get the content and echo it.
12
  $text = file_get_contents($file);
13
  echo $text;
14
 
15
// Convert to JSON to read the status.
16
  $obj = json_decode($text);
17
  // If the process is finished, delete the file.
18
  if ($obj->percent == 100) {
19
    unlink($file);
20
  }
21
}
22
else {
23
  echo json_encode(array("percent" => null, "message" => "File Not Found"));
24
}