public function executeViewSuccess($render) { $fileManager = new Xcck_File($this->mObject); $path_file = $fileManager->getPath($this->_getName()); if (!file_exists($path_file)) { die("Error: File(" . $path_file . ") does not exist"); } if (!($fp = fopen($path_file, "r"))) { die("Error: Cannot open the file(" . $path_file . ")"); } fclose($fp); if (($content_length = filesize($path_file)) == 0) { die("Error: File size is 0.(" . $path_file . ")"); } header("Content-Disposition: inline; filename=\"" . $this->mObject->getShow($this->_getName()) . "\""); header("Content-Length: " . $content_length); header("Content-Type: application/octet-stream"); if (!readfile($path_file)) { die("Cannot read the file(" . $path_file . ")"); } die; //parent::executeViewSuccess($render); }
public function showField($obj, $key, $option = 0) { if ($option == Xcck_ActionType::NONE || $option == Xcck_ActionType::VIEW) { $fileManager = new Xcck_File($obj); if ($fileManager->existFile($key) === true) { $unit = $this->getOption($obj->mDef[$key], 'unit'); $value = sprintf('<a href="%s">%s (%s%s)</a>', Legacy_Utils::renderUri($obj->getDirname(), $obj->getDataname(), $obj->getShow('page_id'), 'download', 'field_name=' . $key), $obj->getShow($key), $fileManager->getFileSize($key, $unit), $unit); } } elseif ($option == Xcck_ActionType::EDIT) { $value = $obj->get($key); } return $value; }
protected function _updateFile() { $fileManager = new Xcck_File($this->mObject); foreach ($this->mObject->mDef as $def) { if ($def->get('field_type') == Xcck_FieldType::FILE) { if ($this->mActionForm->get($def->get('field_name') . '_delete')) { unlink($fileManager->getPath($def->get('field_name'))); } move_uploaded_file($_FILES[$def->get('field_name') . '_file']["tmp_name"], $fileManager->getPath($def->get('field_name'))); } } }