本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::getFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::getFileName方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::getFileName怎么用?PHP Zend_File_Transfer_Adapter_Http::getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::getFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browseAction
/**
* Provides an image browser feature for the rich text editor
*
* @return void
*/
public function browseAction()
{
$params = Zend_Registry::get('params');
// This is displayed inside the editor - so we need set a blank layout (no header/footer)
$this->_helper->layout->setLayout('popup');
$gallery = new Datasource_Cms_Gallery();
$categoryID = $this->getRequest()->getParam('cid');
$editorFuncNum = $this->getRequest()->getParam('CKEditorFuncNum');
if ($this->getRequest()->isPost()) {
// A new image has been sent - handle it
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($params->cms->imageUploadPath);
$upload->addValidator('Extension', false, 'jpg,jpeg,png,gif');
$upload->addValidator('Count', false, 1);
$upload->addValidator('Size', false, 10240000);
if ($upload->receive()) {
// File has been uploaded succesfully
$this->view->uploadSuccess = true;
$imageFilename = $upload->getFileName(null, false);
$imageLocation = $upload->getFileName();
list($imageWidth, $imageHeight) = getimagesize($imageLocation);
$imageID = $gallery->addNew(0, $imageFilename, $imageWidth, $imageHeight);
// Resize and save a few pr
$cmsImage = new Application_Cms_Image();
if ($imageWidth > $imageHeight) {
$cmsImage->resamplePhoto($imageLocation, $params->cms->imageUploadPath . '/previews/200_' . $imageFilename, 200, null);
$cmsImage->resamplePhoto($imageLocation, $params->cms->imageUploadPath . '/previews/400_' . $imageFilename, 400, null);
} else {
$cmsImage->resamplePhoto($imageLocation, $params->cms->imageUploadPath . '/previews/200_' . $imageFilename, null, 150);
$cmsImage->resamplePhoto($imageLocation, $params->cms->imageUploadPath . '/previews/400_' . $imageFilename, null, 400);
}
$this->_helper->getHelper('FlashMessenger')->addMessage(array('deleted' => true));
// $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/images/edit?id='. $imageID); // Forward to image editor
$this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/images/browse?CKEditorFuncNum=' . $editorFuncNum);
} else {
// An error occurred - deal with the error messages
$errorMessages = $upload->getMessages();
}
} else {
// No image uploaded - show the gallery
if (!$categoryID) {
$categoryID = 0;
}
$imageList = $gallery->getImagesByCategoryID($categoryID);
$this->view->imageList = $this->view->partialLoop('partials/image-browser-image.phtml', $imageList);
$this->view->editorFuncNum = $editorFuncNum;
}
}
示例2: updateProfileAction
/**
* Update profile Employee
* @return type
*/
public function updateProfileAction()
{
$this->view->headTitle('Update Profile');
$form = new Employee_Form_UpdateProfile();
$id = (int) $this->getParam('id', '');
if (!$id) {
$this->_helper->redirector('list-profile');
}
$employeeMapper = new Employee_Model_EmployeeMapper();
$result = $employeeMapper->findId($id);
if (!$result) {
$this->view->message = "Nhan vien khong ton tai";
return;
}
$this->view->form = $form;
//set up URL image
$adapter = new Zend_File_Transfer_Adapter_Http();
$uploadPath = APPLICATION_PATH . '/../public/images/avatar';
$adapter->setDestination($uploadPath);
$adapter->addFilter('Rename', $result->getEmployeeId() . '.jpg');
$this->view->fileName = $result->getEmployeeId() . '.jpg';
if (!$adapter->receive()) {
$messages = $adapter->getMessages();
}
$avatar = $adapter->getFileName();
$this->_processShowForm($form, $result);
if ($this->_processUpdateFormProfile($form)) {
echo "Update success";
$this->view->message = "Update success";
$params = array('id' => $id);
$this->_helper->redirector("show-profile", 'profile', 'employee', $params);
}
}
示例3: configAction
function configAction()
{
// When the form is submitted
$form_mess = "";
if (isset($_POST['confName'])) {
$form_mess = $this->updateConfig($_POST, $this->db_v1, $this->view, $this->session);
$this->config_v1 = GetConfig($this->db_v1);
// Check whether the logo file has been transmitted
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination('images/');
$adapter->addValidator('IsImage', false);
if ($adapter->receive()) {
$name = $adapter->getFileName('logo_file');
//récupérer le nom du fichier sans avoir tout le chemin
$name = basename($name);
$this->db_v1->execRequete("UPDATE Config SET logo_file='{$name}'");
}
$config = new Config();
$this->config = $config->fetchAll()->current();
$this->config->putInView($this->view);
$registry = Zend_registry::getInstance();
$registry->set("Config", $this->config);
}
$this->view->config_message = $form_mess;
$this->instantiateConfigVars($this->config_v1, $this->view);
$this->view->setFile("content", "config.xml");
$this->view->setFile("form_config", "form_config.xml");
$form_mess = "";
$this->view->messages = $form_mess;
// N.B: the config values ar eput in the views by the Myreview controller
echo $this->view->render("layout");
}
示例4: uploadFile
public function uploadFile($object, $type, $subtype)
{
$sheets = new SxModule_Sheets();
$base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
$path = $type . '/' . $subtype;
if (!is_dir($base . '/' . $path)) {
echo $base . '/' . $path;
mkdir($base . '/' . $type);
mkdir($base . '/' . $path);
}
if ($object->getFile() == null) {
$object->setFile('');
}
$uploadAdapter = new Zend_File_Transfer_Adapter_Http();
$uploadAdapter->setDestination($base . '/' . $path);
$uploadAdapter->setOptions(array('ignoreNoFile' => true));
$uploadAdapter->receive();
$files = $uploadAdapter->getFileName(null, true);
foreach ($_FILES['file']['name'] as $key => $filename) {
if (!$filename) {
continue;
}
$file = $base . '/' . $path . '/' . $filename;
$date = date('Y-m-d His');
$path_info = pathinfo($filename);
$myfilename = str_replace(' ', '_', $path_info['filename'] . '_' . $date . '.' . $path_info['extension']);
$myfilename = $sheets->createFileName($myfilename);
$newfile = $base . '/' . $path . '/' . $myfilename;
rename($file, $newfile);
$object->setFile($myfilename);
}
}
示例5: uploadphotoAction
public function uploadphotoAction()
{
if ($this->getRequest()->isPost()) {
if ($_FILES['photo']['name'][0] != '') {
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Zend_Registry::get('userImagesPath'));
$files = $adapter->getFileInfo();
$i = 1;
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
$this->view->sendConfirm = 'Problem uploading files';
return $this->render('error');
}
$extension = strtolower(end(explode('.', $info['name'])));
$name = time() . '4' . $i . "." . $extension;
$i++;
$adapter->addFilter('Rename', array('target' => Zend_Registry::get('userImagesPath') . $name, 'overwrite' => TRUE));
if (!$adapter->receive($info['name'])) {
return $this->render('error');
}
}
$filename = $adapter->getFileName();
$filename = basename($filename);
$profile = array('photo' => $filename);
if (($edited = $this->profileService->editProfile(2, $profile)) === TRUE) {
$this->view->profile = $this->profileService->fetchProfile(2);
} else {
$this->view->profile = $edited;
}
$this->render('getprofile');
}
}
}
示例6: addAction
public function addAction()
{
SxCms_Acl::requireAcl('securedocs', 'securedocs.add');
$base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
$path = base64_decode($this->_getParam('path'));
if ($this->getRequest()->isPost()) {
$uploadAdapter = new Zend_File_Transfer_Adapter_Http();
$uploadAdapter->setDestination($base . $path);
$uploadAdapter->setOptions(array('ignoreNoFile' => true));
$uploadAdapter->receive();
$files = $uploadAdapter->getFileName(null, true);
foreach ($_FILES['file']['name'] as $key => $filename) {
if (!$filename) {
continue;
}
$summary = $this->_getParam('samenvatting');
$mail = $this->_getParam('mail', '');
$file = $base . $path . '/' . $filename;
$newfile = $base . $path . '/' . str_replace(" ", "", $filename);
rename($file, $newfile);
$file = new SxModule_Securedocs_File($newfile);
$file->setPath($path);
$file->setSummary($summary[$key]);
$file->setMail(isset($mail[$key]) ? "1" : "0");
$file->save();
if ($mail[$key]) {
$groups = explode('/', $path);
$control = $path;
if ($control != "") {
$proxy = new SxModule_Securedocs_Folder_Proxy();
$folder = $proxy->getByFolder($groups[1]);
$folderId = $folder->getFolderId();
$proxy = new SxModule_Securedocs_Group_Proxy();
$groups = $proxy->getAllByMap($folderId);
$aantal = count($groups);
$q = 0;
$groupids = '(';
foreach ($groups as $group) {
$q++;
if ($q != $aantal) {
$groupids .= $group->getGroupId() . ",";
} else {
$groupids .= $group->getGroupId();
}
}
$groupids .= ')';
$proxy = new SxModule_Members_Proxy();
$members = $proxy->getAllByGroups($groupids);
foreach ($members as $member) {
$member->sendDocument($file);
}
}
}
}
$this->_redirect('/admin/securedocs/index/path/' . base64_encode($path));
}
$this->view->path = $path;
$this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Securedocs_File');
}
示例7: uploadAction
/**
* upload
*/
public function uploadAction()
{
// disable layouts for this action:
$this->_helper->layout->disableLayout();
if ($this->_request->isPost()) {
try {
$destination = PUBLIC_PATH . "/uploads/files";
/* Check destination folder */
if (!is_dir($destination)) {
if (is_writable(PUBLIC_PATH . "/uploads")) {
mkdir($destination);
} else {
throw new Exception("Uploads directory is not writable");
}
}
/* Uploading Document File on Server */
$upload = new Zend_File_Transfer_Adapter_Http();
try {
// upload received file(s)
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
// you MUST use following functions for knowing about uploaded file
// Returns the file name for 'doc_path' named file element
$filePath = $upload->getFileName('file');
// pathinfo
$name = pathinfo($filePath, PATHINFO_FILENAME);
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
// prepare filename
$name = strtolower($name);
$name = preg_replace('/[^a-z0-9_-]/', '-', $name);
// prepare extension
if ($ext == 'php' or $ext == 'php4' or $ext == 'php5' or $ext == 'phtml') {
$ext = 'phps';
}
// rename uploaded file
$renameFile = $name . '.' . $ext;
$counter = 0;
while (file_exists($destination . '/' . $renameFile)) {
$counter++;
$renameFile = $name . '-' . $counter . '.' . $ext;
}
$fileIco = $this->getIco($ext);
$fullFilePath = $destination . '/' . $renameFile;
// Rename uploaded file using Zend Framework
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
$filterFileRename->filter($filePath);
$this->_helper->viewRenderer->setNoRender(true);
$link = '<a href="javascript:void(null);" rel="' . $renameFile . '" class="redactor_file_link redactor_file_ico_' . $fileIco . '" title="' . $renameFile . '">' . $renameFile . '</a>';
echo $link;
} catch (Exception $e) {
$this->_forwardError($e->getMessage());
}
} else {
$this->_forwardError('Internal Error of Uploads controller');
}
}
示例8: _transferFile
/**
* Use the Zend_File_Transfer adapter to upload the file.
*
* @internal The resulting filename is retrieved via the adapter's
* getFileName() method.
*
* @param array $fileInfo
* @param string $originalFilename
* @return string Path to the file in Omeka.
*/
protected function _transferFile($fileInfo, $originalFilename)
{
// Upload a single file at a time.
if (!$this->_adapter->receive($fileInfo['form_index'])) {
throw new Omeka_File_Ingest_InvalidException(join("\n\n", $this->_adapter->getMessages()));
}
// Return the path to the file as it is listed in Omeka.
return $this->_adapter->getFileName($fileInfo['form_index']);
}
示例9: indexAction
public function indexAction()
{
SxCms_Acl::requireAcl('filemanager', 'filemanager.index');
$base = APPLICATION_PATH . '/../public_html/files/';
$base = realpath($base);
$path = base64_decode($this->_getParam('path'));
if ($this->getRequest()->isPost()) {
if (null !== $this->_getParam('folder')) {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.folder');
if (strlen($this->_getParam('folder'))) {
$dirname = $path . '/' . $this->_getParam('folder');
mkdir($base . $dirname);
$this->_redirect('/admin/filemanager/index/path/' . base64_encode($path));
}
} else {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.file');
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(realpath($base) . $path);
if ($adapter->receive()) {
$filename = realpath($adapter->getFileName('filename'));
$file = new SxCms_File($filename);
$path = $file->getPathnameFromBase();
$nfile = $path . '/' . $file->getBasename();
$this->_redirect('/admin/filemanager/edit/file/' . base64_encode($nfile) . '/path/' . base64_encode($path));
} else {
$msg = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
$msg->addMessage('file', $adapter->getMessages());
}
}
}
$this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
try {
$it = new SxCms_Filesystem(realpath($base . $path));
} catch (Exception $e) {
$it = new SxCms_Filesystem($base);
$path = '';
$e;
}
$topdir = explode('/', $path);
if (count($topdir) > 1) {
array_pop($topdir);
$topdir = implode('/', $topdir);
} else {
$topdir = '';
}
$this->view->files = $it;
$this->view->path = $path;
$this->view->showpath = explode('/', $path);
$this->view->topdir = $topdir;
if ($this->_getParam('full')) {
$this->_helper->layout->setLayout('nolayout');
$this->view->full = true;
}
}
示例10: rpsProcessarAction
/**
* Processa os dados do formulário de importação de RPS [json]
*
* @return void
*/
public function rpsProcessarAction()
{
parent::noLayout();
$oForm = new Contribuinte_Form_ImportacaoArquivo();
$oForm->renderizaCamposRPS();
// Adiciona a validação do arquivo junto ao restante das mensagens de erro do form
$aDados = array_merge($this->getRequest()->getPost(), array('isUploaded' => $oForm->arquivo->isUploaded()));
// Valida o formulario e processa a importação
if ($this->getRequest()->isPost() && $oForm->arquivo->isUploaded()) {
$oArquivoUpload = new Zend_File_Transfer_Adapter_Http();
try {
$oArquivoUpload->setDestination(APPLICATION_PATH . '/../public/tmp/');
// Confirma o upload e processa o arquivo
if ($oArquivoUpload->receive()) {
$oImportacaoModelo1 = new Contribuinte_Model_ImportacaoArquivoRpsModelo1();
$oImportacaoModelo1->setArquivoCarregado($oArquivoUpload->getFileName());
$oArquivoCarregado = $oImportacaoModelo1->carregar();
if ($oArquivoCarregado != NULL && $oImportacaoModelo1->validaArquivoCarregado()) {
// Valida as regras de negócio e processa a importação
$oImportacaoProcessamento = new Contribuinte_Model_ImportacaoArquivoProcessamento();
$oImportacaoProcessamento->setCodigoUsuarioLogado($this->usuarioLogado->getId());
$oImportacaoProcessamento->setArquivoCarregado($oArquivoCarregado);
// Processa a importação
$oImportacao = $oImportacaoProcessamento->processarImportacaoRps();
if ($oImportacao->getId()) {
$sUrlRecibo = "/contribuinte/importacao-arquivo/rps-recibo/id/{$oImportacao->getId()}";
$aRetornoJson['status'] = TRUE;
$aRetornoJson['url'] = $this->view->baseUrl($sUrlRecibo);
$aRetornoJson['success'] = $this->translate->_('Arquivo importado com sucesso.');
} else {
throw new Exception($this->translate->_('Ocorreu um erro ao importar o arquivo.'));
}
} else {
throw new Exception($oImportacaoModelo1->processaErroSistema());
}
}
} catch (DBSeller_Exception_ImportacaoXmlException $oErro) {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['error'] = array_merge(array('<b>' . $this->translate->_('Ocorreu um erro ao importar o arquivo:') . '</b><br>'), $oErro->getErrors());
} catch (Exception $oErro) {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['error'][] = $oErro->getMessage();
}
if (is_file($oArquivoUpload->getFileName())) {
unlink($oArquivoUpload->getFileName());
}
} else {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['fields'] = array_keys($oForm->getMessages());
$aRetornoJson['error'][] = $this->translate->_('Preencha os dados corretamente.');
}
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
示例11: upload
/**
* Upload Function
*
* Esta função faz upload do arquivo, renomeia e seta os atriutos
* filename, filehash, filesize
*
* @return boolean
*/
public function upload()
{
/* Verifica se ha arquivo para upload */
$upload = new Zend_File_Transfer_Adapter_Http();
if ($upload->isValid($this->field)) {
$this->filename = $upload->getFileName($this->field, false);
$this->filehash = md5(time() . microtime(true)) . "." . $this->getExtension($this->filename);
$this->filesize = $upload->getFileSize();
$upload->setDestination($this->path)->setFilters(array("Rename" => $this->filehash));
return $upload->receive($this->field);
} else {
return false;
}
}
示例12: addAction
public function addAction()
{
$userNs = new Zend_Session_Namespace("members");
$this->view->title = "City - Add";
$this->view->headTitle(" - " . $this->view->title);
$form = new Admin_Form_City();
$this->view->form = $form;
$this->view->successMsg = "";
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$upload = new Zend_File_Transfer_Adapter_Http();
//---main image
if ($upload->isValid('logo')) {
$upload->setDestination("images/logo/");
try {
$upload->receive('logo');
} catch (Zend_File_Transfer_Exception $e) {
$msg = $e->getMessage();
}
$upload->setOptions(array('useByteString' => false));
$id = time();
$file_name = $upload->getFileName('logo');
$cardImageTypeArr = explode(".", $file_name);
$ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
$target_file_name = "logo_" . $id . ".{$ext}";
$targetPath = 'media/picture/city/logo/' . $target_file_name;
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
$filterFileRename->filter($file_name);
$formData['logo'] = $target_file_name;
/*--- Generate Thumbnail ---*/
$thumb = Base_Image_PhpThumbFactory::create($targetPath);
$thumb->resize(100, 100);
$thumb->save($targetPath = 'media/picture/city/logo/thumb_' . $target_file_name);
}
$usersNs = new Zend_Session_Namespace("members");
$formData['userId'] = $usersNs->userId;
$this->view->warningMsg = '';
$model = new Application_Model_City($formData);
$id = $model->save($model);
$form->reset();
$this->view->successMsg = "City added successfully. City Id : {$id}";
} else {
$form->populate($formData);
}
}
}
示例13: save
public function save($path, $extension, $userid = 0)
{
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($path);
$files = $adapter->getFileInfo();
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
return false;
}
$filename = $this->generateFileName($extension, $userid);
$adapter->addFilter('Rename', array('target' => $path . $filename, 'overwrite' => TRUE));
if (!$adapter->receive($info['name'])) {
return false;
}
}
$filename = $adapter->getFileName();
$filename = basename($filename);
return $filename;
}
示例14: addAction
public function addAction()
{
$this->view->title = "Добавить страницу";
$this->view->headTitle($this->view->title, 'PREPEND');
$frmPage = new Form_Page();
if ($this->_request->isPost()) {
if ($frmPage->isValid($this->_request->getParams())) {
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(SITE_PATH . 'img' . DS . 'upload');
$adapter->receive();
$fileName = $adapter->getFileName('image', false);
$paramStr = $frmPage->getValues();
$paramStr['image'] = $fileName;
$mdlPages = new Model_Admin();
$mdlPages->fill($paramStr);
$mdlPages->save();
$this->_helper->redirector('index');
}
}
$this->view->form = $frmPage;
}
示例15: processarImportacaoAction
/**
* Action resposável pela importção da DES-IF
*/
public function processarImportacaoAction()
{
parent::noLayout();
try {
$aDados = $this->getRequest()->getPost();
$oForm = new Contribuinte_Form_ImportacaoDesif();
if ($oForm->isValid($aDados)) {
$oArquivoUpload = new Zend_File_Transfer_Adapter_Http();
if ($oArquivoUpload->receive()) {
$aArquivos = $oArquivoUpload->getFileName();
$aArquivoContas = file($aArquivos['arquivoContas']);
$aArquivoReceita = file($aArquivos['arquivoReceita']);
$oContribuinte = $this->_session->contribuinte;
$oImportacaoDesif = new Contribuinte_Model_Desif($oContribuinte, $aArquivoContas, $aArquivoReceita);
$iImportacaoDesifId = $oImportacaoDesif->processarArquivo();
//Gera protocolo e vincula com a importação
$sMensagem = 'Processamento efetuado com sucesso!';
$oProtocolo = $this->adicionaProtocolo(2, $sMensagem);
$oDesif = Contribuinte_Model_ImportacaoDesif::getById($iImportacaoDesifId);
$oDesif->setProtocolo($oProtocolo);
$oDesif->persist();
$aRetornoJson['status'] = TRUE;
$aRetornoJson['success'] = $this->translate->_($sMensagem);
$aRetornoJson['protocolo'] = $oProtocolo->getProtocolo();
}
} else {
throw new Exception("Preencha os dados corretamente.");
}
} catch (Exception $oErro) {
//Gera Protocolo
$sMensagem = $oErro->getMessage();
$oProtocolo = $this->adicionaProtocolo(1, $sMensagem);
$aRetornoJson['status'] = FALSE;
$aRetornoJson['error'][] = $sMensagem;
$aRetornoJson['protocolo'] = $oProtocolo->getProtocolo();
}
echo $this->getHelper('json')->sendJson($aRetornoJson);
}