setKey($uploadKey)->getOffset(); $status = false !== $offset ? 'resume' : 'new'; $offset = false === $offset ? 0 : $offset; echo json_encode([ 'status' => $status, 'bytes_uploaded' => $offset, 'upload_key' => $uploadKey, ]); $myfile = fopen("newfile.txt", "a") or die("Unable to open file!"); $txt = $status." sucess?\n".$offset."\n"; fwrite($myfile, $txt); } catch (ConnectException $e) { echo json_encode([ 'status' => 'error', 'bytes_uploaded' => -1, ]); $myfile = fopen("newfile.txt", "a") or die("Unable to open file!"); $txt = "error?\n"; fwrite($myfile, $txt); } catch (FileException $e) { echo json_encode([ 'status' => 'resume', 'bytes_uploaded' => 0, 'upload_key' => '', ]); $myfile = fopen("newfile.txt", "a") or die("Unable to open file!"); $txt = "what?\n"; fwrite($myfile, $txt); }