Esempio n. 1
0
 private function mockFileUpload($filePath)
 {
     $cfu = new ChessFileUpload();
     $tokens = explode("/", $filePath);
     $tokens[1] = "tmp-" . $tokens[1];
     $newFilePath = implode("/", $tokens);
     copy($filePath, $newFilePath);
     $_FILES = array(array('size' => filesize($newFilePath), 'name' => $tokens[1], 'tmp_name' => $newFilePath));
     $cfu->save();
     return $cfu->getId();
 }
 public function __construct($id = null)
 {
     if (!isset(self::$tempPath)) {
         self::$tempPath = LudoDBRegistry::get(self::FILE_UPLOAD_KEY);
         if (!isset(self::$tempPath)) {
             throw new Exception("Temp path for file uploads not set. Use LudoDBRegistry::set(self::FILE_UPLOAD_KEY, 'your/path'); to set path", 500);
         }
     }
     parent::__construct($id);
 }
Esempio n. 3
0
 private function getFilePath($request)
 {
     if (isset($request['file'])) {
         return $request['file'];
     }
     if (isset($request['pgnFile']) && is_numeric($request['pgnFile'])) {
         $file = new ChessFileUpload($request['pgnFile']);
         return $file->getPathOnServer();
     }
     return false;
 }