/** * Set the temporary file * * @param \GO\Base\Fs\File $file * @throws Exception */ public function setTempFile(\GO\Base\Fs\File $file) { if (!$file->isTempFile()) { throw new \Exception("File {$file->name} is not a temporary file"); } $this->_tmp_file = $file->stripTempPath(); }
protected function actionPluploads($params) { if (isset($params['addFileStorageFiles'])) { $files = json_decode($params['addFileStorageFiles'], true); foreach ($files as $filepath) { GO::session()->values['files']['uploadqueue'][] = GO::config()->file_storage_path . $filepath; } } $response['results'] = array(); if (!empty(GO::session()->values['files']['uploadqueue'])) { foreach (GO::session()->values['files']['uploadqueue'] as $path) { $file = new \GO\Base\Fs\File($path); $result = array('human_size' => $file->humanSize(), 'extension' => strtolower($file->extension()), 'size' => $file->size(), 'type' => $file->mimeType(), 'name' => $file->name()); if ($file->isTempFile()) { $result['from_file_storage'] = false; $result['tmp_file'] = $file->stripTempPath(); } else { $result['from_file_storage'] = true; $result['tmp_file'] = $file->stripFileStoragePath(); } $response['results'][] = $result; } } $response['total'] = count($response['results']); unset(GO::session()->values['files']['uploadqueue']); return $response; }