public function fileGet(Silex\Application $app)
 {
     $request = new \Flow\Request();
     $chunkNumber = $request->getCurrentChunkNumber() ?: 0;
     $chunkSize = $request->getDefaultChunkSize() ?: 0;
     $totalSize = $request->getTotalSize() ?: 0;
     $identifier = $request->getIdentifier() ?: '';
     $filename = $request->getFileName() ?: '';
     if ($this->validateRequest($chunkNumber, $chunkSize, $totalSize, $identifier, $filename) == 'valid') {
         $chunkFilename = $this->getChunkFilename($chunkNumber, $identifier);
         if (realpath($chunkFilename) !== false) {
             utils::log($request->param('REQUEST_METHOD') . 'found');
             return new Response('', Response::HTTP_OK, ['Content-Type' => 'text/plain']);
         }
     }
     return new Response('', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/plain']);
 }
Exemplo n.º 2
0
<?
require_once './vendor/Flow/Autoloader.php';
require_once 'dbfunctions.php';
require_once 'fileparams.php';
Flow\Autoloader::register();

$config = new \Flow\Config();
$config->setTempDir($chunkFolder);
$file = new \Flow\File($config);
$request = new \Flow\Request();

function getImgExtension($fname){
	preg_match("/^.*\.(jpg|jpeg|png|gif)$/i", $fname, $out);
	return strtolower($out[1]);
}

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if ($file->checkChunk()) {
        header("HTTP/1.1 200 Ok");
    } else {
        header("HTTP/1.1 204 No Content");
        return ;
    }
} else {
  if ($file->validateChunk()) {
      $file->saveChunk();
  } else {
      // error, invalid chunk upload request, retry
      header("HTTP/1.1 400 Bad Request");
      return ;
  }