/** * Move converted file to a new location * @param $destination The destination of the moved file */ public function moveTo($destination) { if (isset($this->_file['in_request']) && $this->_file['in_request'] == true) { $data = $this->_uploadedFile->getPackage()->getPackageField(sprintf(PostFields::file, $this->_convertedFileIndex, $this->_uploadedFileIndex)); $handle = fopen($destination, 'w'); $result = fwrite($handle, $data); if ($result !== FALSE) { // no error $result = TRUE; } $result &= fclose($handle); } else { $path = $this->_file['tmp_name']; if (is_uploaded_file($path)) { $result = move_uploaded_file($path, $destination); } else { if ($this->_file['cached']) { $result = UploadCache::moveFile($path, $destination); } else { throw new Exception('File is not "is_uploaded_file" and is not cached file'); } } } if (!$result) { throw new Exception("Unable to move file \"{$path}\" to \"{$destination}\""); } }