/** * Updates the file name of the token (if empty) using the file name from the file data */ protected function updateFileName($fileData) { if (!$this->_uploadToken->getFileName()) { $this->_uploadToken->setFileName(isset($fileData['name']) ? $fileData['name'] : null); $this->_uploadToken->save(); } }
/** * Move the uploaded file * @param unknown_type $fileData */ protected function handleMoveFile($fileData) { // get the upload path $extension = strtolower(pathinfo($fileData['name'], PATHINFO_EXTENSION)); // in firefox html5 upload the extension is missing (file name is "blob") so try fetching the extesion from // the original file name that was passed to the uploadToken if ($extension === "" || $extension == "tmp" && $this->_uploadToken->getFileName()) { $extension = strtolower(pathinfo($this->_uploadToken->getFileName(), PATHINFO_EXTENSION)); } $uploadFilePath = $this->getUploadPath($this->_uploadToken->getId(), $extension); $this->_uploadToken->setUploadTempPath($uploadFilePath); kFile::fullMkdir($uploadFilePath, 0700); $moveFileSuccess = kFile::moveFile($fileData['tmp_name'], $uploadFilePath); if (!$moveFileSuccess) { $msg = "Failed to move uploaded file for token id [{$this->_uploadToken->getId()}]"; KalturaLog::log($msg . ' ' . print_r($fileData, true)); throw new kUploadTokenException($msg, kUploadTokenException::UPLOAD_TOKEN_FAILED_TO_MOVE_UPLOADED_FILE); } chmod($uploadFilePath, 0600); }