当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_File_Transfer_Adapter_Http::getMimeType方法代码示例

本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::getMimeType方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::getMimeType怎么用?PHP Zend_File_Transfer_Adapter_Http::getMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_File_Transfer_Adapter_Http的用法示例。


在下文中一共展示了Zend_File_Transfer_Adapter_Http::getMimeType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: versionAction

 /**
  * versionAction
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 public function versionAction()
 {
     try {
         $this->core->logger->debug('media->controllers->UploadController->versionAction()');
         $this->handleFileTransfer();
         if ($this->getRequest()->isPost()) {
             $objRequest = $this->getRequest();
             $this->intFileId = $objRequest->getParam('fileId');
             /**
              * check if is image or else document
              */
             if ($this->intFileId > 0 && $this->intFileId != '') {
                 if (strpos($this->objUpload->getMimeType(self::UPLOAD_FIELD), 'image/') !== false) {
                     $this->handleImageVersionUpload();
                 } else {
                     if (strpos($this->objUpload->getMimeType(self::UPLOAD_FIELD), 'video/') !== false || $this->objUpload->getMimeType(self::UPLOAD_FIELD) == 'application/x-shockwave-flash') {
                         $this->handleVideoVersionUpload();
                     } else {
                         $this->handleFileVersionUpload();
                     }
                 }
             }
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:32,代码来源:UploadController.php

示例2: _getMimeType

 protected function _getMimeType()
 {
     if (extension_loaded('fileinfo')) {
         return $this->_uploadHandler->getMimeType();
     }
     $files = $this->_uploadHandler->getFileInfo();
     if (empty($files)) {
         return false;
     }
     $file = reset($files);
     unset($files);
     if (function_exists('getimagesize')) {
         $info = getimagesize($file['tmp_name']);
         return $info !== false ? $info['mime'] : false;
     }
     return false;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:17,代码来源:UploadController.php

示例3: indexAction

 /**
  * indexAction
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 public function indexAction()
 {
     try {
         $this->core->logger->debug('media->controllers->UploadController->indexAction()');
         $this->objUpload = new Zend_File_Transfer_Adapter_Http();
         /**
          * validators for upload of media
          */
         $arrExcludedExtensions = $this->core->sysConfig->upload->excluded_extensions->extension->toArray();
         $this->objUpload->addValidator('Size', false, array('min' => 1, 'max' => $this->core->sysConfig->upload->max_filesize));
         $this->objUpload->addValidator('ExcludeExtension', false, $arrExcludedExtensions);
         /**
          * check if medium is uploaded
          */
         if (!$this->objUpload->isUploaded(self::UPLOAD_FIELD)) {
             $this->core->logger->warn('isUploaded: ' . implode('\\n', $this->objUpload->getMessages()));
             throw new Exception('File is not uploaded!');
         }
         /**
          * check if upload is valid
          */
         //      if (!$this->objUpload->isValid(self::UPLOAD_FIELD)) {
         //        $this->core->logger->warn('isValid: '.implode('\n', $this->objUpload->getMessages()));
         //      	throw new Exception('Uploaded file is not valid!');
         //      }
         if ($this->getRequest()->isPost()) {
             $objRequest = $this->getRequest();
             $this->intParentId = $objRequest->getParam('folderId');
             /**
              * check if is image or else document
              */
             if ($this->intParentId > 0 && $this->intParentId != '') {
                 if (strpos($this->objUpload->getMimeType(self::UPLOAD_FIELD), 'image/') !== false) {
                     $this->handleImageUpload();
                 } else {
                     $this->handleFileUpload();
                 }
             }
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:48,代码来源:UploadController.php

示例4: pathinfo

$view = new Zend_View();
$view->setScriptPath(__DIR__);
// Tell all the elements in the form which view to use when rendering
foreach ($form as $item) {
    $item->setView($view);
}
// process or display the form
if (isset($_POST['submit']) && $form->isValid($_POST)) {
    $uploadHandler = new Zend_File_Transfer_Adapter_Http();
    $uploadHandler->setDestination(__DIR__ . '/uploads/');
    try {
        $uploadHandler->receive();
        $data = $form->getValues();
        Zend_Debug::dump($data, 'Form Data:');
        $fullPath = $uploadHandler->getFileName('file');
        $size = $uploadHandler->getFileSize('file');
        $mimeType = $uploadHandler->getMimeType('file');
        $fileInfo = pathinfo($fullPath);
        $name = $fileInfo['basename'] . '<br>';
        // rename the file for security purpose
        $newName = 'RM_' . time() . '_' . $fileInfo['basename'];
        $fullFilePath = __DIR__ . '/uploads/' . $newName;
        $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
        $filterFileRename->filter($fullPath);
        echo 'thanks <br />';
    } catch (Zend_File_Transfer_Exception $e) {
        echo $e->getMessage();
    }
} else {
    echo $form->render($view);
}
开发者ID:rmuktader,项目名称:zf-stand-alone-upload-form,代码行数:31,代码来源:form.php

示例5: uploadAction

 /**
  * Index
  *
  * @throws Exception
  */
 public function uploadAction()
 {
     // disable layouts for this action:
     $this->_helper->layout->disableLayout();
     if ($this->_request->isPost()) {
         try {
             $destination = PUBLIC_PATH . $this->_uploadPath . DS . $this->_getUploadDir();
             $publicPath = $this->_uploadPath . DS . $this->_getUploadDir();
             /* Check destination folder */
             if (!is_dir($destination)) {
                 if (is_writable(PUBLIC_PATH . $this->_uploadPath)) {
                     mkdir($destination, 0777, true);
                 } 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');
             // Returns the mimetype for the 'file' form element
             $mimeType = $upload->getMimeType('file');
             // mimeType validation
             switch ($mimeType) {
                 case 'image/jpg':
                 case 'image/jpeg':
                 case 'image/pjpeg':
                     $ext = 'jpg';
                     break;
                 case 'image/png':
                     $ext = 'png';
                     break;
                 case 'image/gif':
                     $ext = 'gif';
                     break;
                 default:
                     throw new Exception('Wrong mimetype of uploaded file. Received "' . $mimeType . '"');
                     break;
             }
             // prepare filename
             $name = pathinfo($filePath, PATHINFO_FILENAME);
             $name = strtolower($name);
             $name = preg_replace('/[^a-z0-9_-]/', '-', $name);
             // rename uploaded file
             $renameFile = $name . '.' . $ext;
             $counter = 0;
             while (file_exists($destination . '/' . $renameFile)) {
                 $counter++;
                 $renameFile = $name . '-' . $counter . '.' . $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);
             // create thumb
             $this->_createThumb($fullFilePath);
             echo "<img src='{$publicPath}/{$renameFile}' alt='' />";
         } catch (Exception $e) {
             $this->_forwardError($e->getMessage());
         }
     } else {
         $this->_forwardError('Internal Error of Uploads controller');
     }
 }
开发者ID:shahmaulik,项目名称:zfcore,代码行数:77,代码来源:Images.php

示例6: receiveformAction

 public function receiveformAction()
 {
     if ($this->getRequest()->isPost()) {
         $xmlHttpRequest = $this->_request->isXmlHttpRequest();
         $formParams = $this->getRequest()->getParams();
         $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session');
         if (!empty($formParams)) {
             $websiteConfig = Zend_Controller_Action_HelperBroker::getExistingHelper('config')->getConfig();
             $formMapper = Application_Model_Mappers_FormMapper::getInstance();
             // get the form details
             $form = $formMapper->findByName($formParams['formName']);
             $useCaptcha = $form->getCaptcha();
             //hidden input validation
             $formName = $form->getName();
             $formId = $form->getId();
             if (!isset($formParams[md5($formName . $formId)]) || $formParams[md5($formName . $formId)] != '') {
                 if ($xmlHttpRequest) {
                     $this->_helper->response->success($form->getMessageSuccess());
                 }
                 $this->_redirect($formParams['formUrl']);
             }
             unset($formParams[md5($formName . $formId)]);
             //validating recaptcha
             if ($useCaptcha == 1) {
                 if (!empty($websiteConfig) && !empty($websiteConfig[Tools_System_Tools::RECAPTCHA_PUBLIC_KEY]) && !empty($websiteConfig[Tools_System_Tools::RECAPTCHA_PRIVATE_KEY]) && isset($formParams['recaptcha_challenge_field']) || isset($formParams['captcha'])) {
                     if (isset($formParams['recaptcha_challenge_field']) && isset($formParams['recaptcha_response_field'])) {
                         if ($formParams['recaptcha_response_field'] == '') {
                             if ($xmlHttpRequest) {
                                 $this->_helper->response->fail($this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.'));
                             }
                             $sessionHelper->toasterFormError = $this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.');
                             $this->_redirect($formParams['formUrl']);
                         }
                         $recaptcha = new Zend_Service_ReCaptcha($websiteConfig[Tools_System_Tools::RECAPTCHA_PUBLIC_KEY], $websiteConfig[Tools_System_Tools::RECAPTCHA_PRIVATE_KEY]);
                         $result = $recaptcha->verify($formParams['recaptcha_challenge_field'], $formParams['recaptcha_response_field']);
                         if (!$result->isValid()) {
                             if ($xmlHttpRequest) {
                                 $this->_helper->response->fail($this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.'));
                             }
                             $sessionHelper->toasterFormError = $this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.');
                             $this->_redirect($formParams['formUrl']);
                         }
                         unset($formParams['recaptcha_challenge_field']);
                         unset($formParams['recaptcha_response_field']);
                     } else {
                         //validating captcha
                         if (!$this->_validateCaptcha(strtolower($formParams['captcha']), $formParams['captchaId'])) {
                             if ($xmlHttpRequest) {
                                 $this->_helper->response->fail($this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.'));
                             }
                             $sessionHelper->toasterFormError = $this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.');
                             $this->_redirect($formParams['formUrl']);
                         }
                     }
                 } else {
                     if ($xmlHttpRequest) {
                         $this->_helper->response->fail($this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.'));
                     }
                     $sessionHelper->toasterFormError = $this->_helper->language->translate('You\'ve entered an incorrect security text. Please try again.');
                     $this->_redirect($formParams['formUrl']);
                 }
             }
             $sessionHelper->formName = $formParams['formName'];
             $sessionHelper->formPageId = $formParams['formPageId'];
             unset($formParams['formPageId']);
             unset($formParams['submit']);
             if (isset($formParams['conversionPageUrl'])) {
                 $conversionPageUrl = $formParams['conversionPageUrl'];
                 unset($formParams['conversionPageUrl']);
             }
             $attachment = array();
             if (!$xmlHttpRequest) {
                 //Adding attachments to email
                 $websitePathTemp = $this->_helper->website->getPath() . $this->_helper->website->getTmp();
                 $uploader = new Zend_File_Transfer_Adapter_Http();
                 $uploader->setDestination($websitePathTemp);
                 $uploader->addValidator('Extension', false, self::ATTACHMENTS_FILE_TYPES);
                 //Adding Size limitation
                 $uploader->addValidator('Size', false, $formParams['uploadLimitSize'] * 1024 * 1024);
                 //Adding mime types validation
                 $uploader->addValidator('MimeType', true, array('application/pdf', 'application/xml', 'application/zip', 'text/csv', 'text/plain', 'image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'application/msword', 'application/vnd.ms-excel'));
                 $files = $uploader->getFileInfo();
                 foreach ($files as $file => $fileInfo) {
                     if ($fileInfo['name'] != '') {
                         if ($uploader->isValid($file)) {
                             $uploader->receive($file);
                             $at = new Zend_Mime_Part(file_get_contents($uploader->getFileName($file)));
                             $at->type = $uploader->getMimeType($file);
                             $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
                             $at->encoding = Zend_Mime::ENCODING_BASE64;
                             $at->filename = $fileInfo['name'];
                             $attachment[] = $at;
                             unset($at);
                             Tools_Filesystem_Tools::deleteFile($this->_helper->website->getPath() . $this->_helper->website->getTmp() . $fileInfo['name']);
                         } else {
                             $validationErrors = $uploader->getErrors();
                             $errorMessage = '';
                             foreach ($validationErrors as $errorType) {
                                 if ($errorType == 'fileMimeTypeFalse') {
                                     $errorMessage .= 'Invalid file format type. ';
//.........这里部分代码省略.........
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:101,代码来源:FormController.php

示例7: uploadAction

 public function uploadAction()
 {
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $request = $this->getRequest();
     if (!$request->isPost()) {
         return;
     }
     $user = Zend_Auth::getInstance()->getIdentity();
     $userName = $user->username;
     $type = $request->getParam('type');
     $newguid = $request->getParam('guid');
     $cdn = Pandamp_Application::getOption('cdn');
     if ($type == 'file') {
         $dir = $cdn['static']['dir']['files'];
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $files = $adapter->getFileInfo();
         foreach ($files as $file => $info) {
             $guid = (new Pandamp_Core_Guid())->generateGuid();
             $path = implode(DS, array($newguid));
             Pandamp_Utility_File::createDirs($dir, $path);
             $adapter->setDestination($dir . DS . $path);
             $name = $adapter->getFileName($file, false);
             $fileku = $dir . DS . $path . DS . strtoupper(str_replace(' ', '_', $name));
             $adapter->addFilter('rename', ['overwrite' => true, 'target' => $fileku]);
             // file uploaded & is valid
             if (!$adapter->isUploaded($file)) {
                 continue;
             }
             if (!$adapter->isValid($file)) {
                 continue;
             }
             // receive the files into the user directory
             $adapter->receive($file);
             /*
             $baseUrl = $cdn['static']['url']['files'];
             if (isset($_SERVER['SCRIPT_NAME']) && ($pos = strripos($baseUrl, basename($_SERVER['SCRIPT_NAME']))) !== false) {
             	$baseUrl = substr($baseUrl, 0, $pos);
             }
             $prefixUrl 		 = rtrim($baseUrl, '/') . '/' . $userName . '/' . date('Y') . '/' . date('m');
             $ret['original'] = array(
             	'title' => strtoupper(str_replace(' ','_',$name)),
             	'url'  => $prefixUrl . '/' . strtoupper(str_replace(' ','_',$name)),
             	'size' => $adapter->getFileSize($file),
             	'filetype' => $adapter->getMimeType($file),
             	'type' => $type	
             );
             */
             $ret['original'] = array('id' => $guid, 'title' => strtoupper(str_replace(' ', '_', $name)), 'size' => $adapter->getFileSize($file), 'filetype' => $adapter->getMimeType($file), 'type' => $type);
         }
     } else {
         /*$size = [
         			'square' => 'crop_99_103',
         			'thumbnail' => 'resize_100_53',
         			'multimedia' => 'resize_245_169',
         			'small' => 'resize_213_142', //klinik
         			'headsmall' => 'resize_213_160', //header berita
         			'crop' => 'crop_324_169', //ijt
         			'cropnext' => 'crop_325_183', //nextevent
         			'mainhead' => 'resize_462_309', //utama
         			'medium' => 'resize_646_431'
         		];*/
         $tool = 'gd';
         $size = new Zend_Config_Ini(APPLICATION_PATH . '/configs/image.ini', 'size');
         $sizes = array();
         foreach ($size->toArray() as $key => $value) {
             list($method, $width, $height) = explode('_', $value);
             $sizes[$key] = array('method' => $method, 'width' => $width, 'height' => $height);
         }
         /**
          * Prepare folders
          */
         //$dir  = $cdn['static']['dir']['images'] . DS . 'upload';
         $dir = $cdn['static']['dir']['images'];
         //$path = implode(DS, array($userName, date('Y'), date('m'), date('d')));
         $path = implode(DS, array($newguid));
         Pandamp_Utility_File::createDirs($dir, $path);
         /**
          * Upload file
          */
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination($dir . DS . $path);
         $adapter->addValidator('Extension', false, 'jpg,png,gif');
         $adapter->addValidator('Size', false, 5242880);
         $files = $adapter->getFileInfo();
         foreach ($files as $file => $info) {
             $name = $adapter->getFileName($file);
             $ext = explode('.', $name);
             $extension = $ext[count($ext) - 1];
             $extension = strtolower($extension);
             //$fileName  = uniqid();
             $fileName = (new Pandamp_Core_Guid())->generateGuid();
             $fileku = $dir . DS . $path . DS . $fileName . '.' . $extension;
             $adapter->addFilter('rename', $fileku);
             // file uploaded & is valid
             if (!$adapter->isUploaded($file)) {
                 continue;
             }
             if (!$adapter->isValid($file)) {
                 continue;
//.........这里部分代码省略.........
开发者ID:hukumonline,项目名称:admin,代码行数:101,代码来源:FileController.php

示例8: step3Action

 public function step3Action()
 {
     $this->view->messages = $this->_flashMessenger->getMessages();
     $sessionPost = new Zend_Session_Namespace('step1Post');
     if (isset($sessionPost) && $sessionPost != null && isset($sessionPost->user_id) && $sessionPost->user_id != "") {
         $formData = array();
         $formErrors = array();
         if ($this->getRequest()->isPost()) {
             $formData = $this->getRequest()->getPost();
             //print_r($formData);exit;
             //=====================START FORM VALIDATION===================================
             //=====================END FORM VALIDATION===================================
             if (count($formErrors) == 0) {
                 //=========insert education history========================
                 if (count($formData['education_type']) > 0 && count($formData['school_name']) > 0 && count($formData['years_attended']) > 0) {
                     for ($e = 0; $e < count($formData['education_type']); $e++) {
                         $education_type = $formData['education_type'][$e];
                         $school_name = $formData['school_name'][$e];
                         $years_attended = $formData['years_attended'][$e];
                         if (isset($education_type) && $education_type != "" && (isset($school_name) && $school_name != "") && (isset($years_attended) && $years_attended != "")) {
                             $educationData = array('user_id' => $sessionPost->user_id, 'education_type' => $education_type, 'school_name' => $school_name, 'years_attended' => $years_attended, 'added_date' => date("Y-m-d H:i:s"), 'updated_date' => date("Y-m-d H:i:s"));
                             $this->modelCandidateEducationHistory->insert($educationData);
                         }
                     }
                 }
                 //=========insert employment history========================
                 if (count($formData['employment_company']) > 0) {
                     for ($em = 0; $em < count($formData['employment_company']); $em++) {
                         $employment_company = $formData['employment_company'][$em];
                         $employment_role = $formData['employment_role'][$em];
                         $employment_location = $formData['employment_location'][$em];
                         $employment_month = $formData['employment_month'][$em];
                         $employment_year = $formData['employment_year'][$em];
                         $employment_responsibilities = $formData['employment_responsibilities'][$em];
                         $employment_achievements = $formData['employment_achievements'][$em];
                         //$employment_file_references=$formData['employment_file_references'][$em];
                         if (isset($employment_company) && $employment_company != "") {
                             $employmentData = array('user_id' => $sessionPost->user_id, 'employment_company' => $employment_company, 'employment_role' => $employment_role, 'employment_location' => $employment_location, 'employment_month' => $employment_month, 'employment_year' => $employment_year, 'employment_responsibilities' => $employment_responsibilities, 'employment_achievements' => $employment_achievements, 'added_date' => date("Y-m-d H:i:s"), 'updated_date' => date("Y-m-d H:i:s"));
                             $empId = $this->modelCandidateEmploymentHistory->insert($employmentData);
                             if (isset($empId) && $empId > 0) {
                                 /**** Uploading File on Server*****/
                                 $upload = new Zend_File_Transfer_Adapter_Http();
                                 $upload->setDestination(USER_UPLOAD_DIR);
                                 $files = $upload->getFileInfo('employment_file_references');
                                 if (isset($files) && count($files) > 0) {
                                     $i = 1;
                                     foreach ($files as $file => $info) {
                                         //echo "<pre>";
                                         //print_r($file);
                                         //echo "</pre>";
                                         //exit;
                                         if ($file == 'employment_file_references_' . $em . '_' && $info['name'] != "") {
                                             if ($upload->isValid($file)) {
                                                 try {
                                                     // upload received file(s)
                                                     $upload->receive($file);
                                                 } catch (Zend_File_Transfer_Exception $e) {
                                                     //echo $e->getMessage();//exit;
                                                 }
                                                 // so, Finally lets See the Data that we received on Form Submit
                                                 $name = $upload->getFileName($file);
                                                 $size = $upload->getFileSize($file);
                                                 # Returns the mimetype for the '$file' form element
                                                 $mimeType = $upload->getMimeType($file);
                                                 $renameFile = time() . $i . $info['name'];
                                                 //echo $renameFile;exit;
                                                 $fullFilePath = USER_UPLOAD_DIR . $renameFile;
                                                 //Rename uploaded file using Zend Framework
                                                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
                                                 $filterFileRename->filter($name);
                                                 $logoData = array('employment_file_references' => $renameFile);
                                                 $this->modelCandidateEmploymentHistory->update($logoData, 'id=' . $empId);
                                             }
                                         }
                                         $i++;
                                     }
                                 }
                                 /*****End Uploading************/
                             }
                         }
                     }
                 }
                 //=========insert skills and specialization========================
                 if (isset($formData['specializations']) && count($formData['specializations']) > 0) {
                     $specializations = implode(",", $formData['specializations']);
                     $skills = implode(",", $formData['skills']);
                     $skillsData = array('user_id' => $sessionPost->user_id, 'specializations' => $specializations, 'skills' => $skills, 'driving_license' => $driving_license, 'added_date' => date("Y-m-d H:i:s"), 'updated_date' => date("Y-m-d H:i:s"));
                     $this->modelCandidateSkillsSpecializations->insert($skillsData);
                 }
                 //========unset the session of step1 form data====
                 Zend_Session::namespaceUnset('step1Post');
                 //=================================================
                 $this->_redirect('user/register/thanks');
             } else {
                 $this->view->errorMessage = '<div class="div-error">Sorry, unable to add, please try later.</div>';
             }
         }
         $this->view->formData = $formData;
         $this->view->formErrors = $formErrors;
     } else {
//.........这里部分代码省略.........
开发者ID:vmangla,项目名称:evendor,代码行数:101,代码来源:RegisterController_old.php

示例9: upload

 public function upload()
 {
     if ($this->_helper->Identity()) {
         //Check if images path directory is writable
         if (!is_writable(IMAGE_PATH)) {
             throw new Pas_Exception_NotAuthorised('The images directory is not writable', 500);
         }
         // Create the imagedir path
         $imagedir = IMAGE_PATH . '/' . $this->_helper->Identity()->username;
         //Check if a directory and if not make directory
         if (!is_dir($imagedir)) {
             mkdir($imagedir, 0775, true);
         }
         //Check if the personal image directory is writable
         if (!is_writable($imagedir)) {
             throw new Pas_Exception_NotAuthorised('The user image directory is not writable', 500);
         }
         // Get images and do the magic
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination($imagedir);
         $adapter->setOptions(array('useByteString' => false));
         // Only allow good image files!
         $adapter->addValidator('Extension', false, 'jpg, tiff');
         $adapter->addValidator('NotExists', false, array($imagedir));
         $files = $adapter->getFileInfo();
         // Create an array for the images
         $images = array();
         // Loop through the submitted files
         foreach ($files as $file => $info) {
             // file uploaded & is valid
             //                if (!$adapter->isUploaded($file)) continue;
             //                if (!$adapter->isValid($file)) continue;
             // Clean up the image name for crappy characters
             $filename = pathinfo($adapter->getFileName($file));
             // Instantiate the renamer
             $reNamer = new Pas_Image_Rename();
             // Clean the filename
             $cleaned = $reNamer->strip($filename['filename'], $filename['extension']);
             // Rename the file
             $adapter->addFilter('rename', $cleaned);
             // receive the files into the user directory
             $adapter->receive($file);
             // this has to be on top
             if (!$adapter->hasErrors()) {
                 // Create the object for reuse
                 $image = new stdClass();
                 $image->cleaned = $cleaned;
                 $image->basename = $filename['basename'];
                 $image->extension = $filename['extension'];
                 $image->thumbnailUrl = $this->createThumbnailUrl($adapter->getFileName($file, false));
                 $image->deleteUrl = $this->_createUrl($adapter->getFileName($file, false));
                 $image->path = $adapter->getFileName($file);
                 $image->name = $adapter->getFileName($file, false);
                 $image->size = $adapter->getFileSize($file);
                 $image->mimetype = $adapter->getMimeType($file);
                 // The secure ID stuff for linking images
                 $image->secuid = $this->_helper->GenerateSecuID();
                 // Get the image dims
                 $imagesize = getimagesize($adapter->getFileName($file));
                 $image->width = $imagesize[0];
                 $image->height = $imagesize[1];
                 $params = $this->getAllParams();
                 $image->findID = $params['findID'];
                 // Create the raw image url
                 $image->url = $this->_createUrl($adapter->getFileName($file, false));
                 $image->deleteType = 'DELETE';
                 $images[] = $image;
                 $slides = new Slides();
                 $insert = $slides->addAndResize($images);
                 $this->view->data = $images;
                 $this->_helper->solrUpdater->update('images', (int) $insert);
                 $this->_helper->solrUpdater->update('objects', $params['findID'], 'artefacts');
             } else {
                 $image = new stdClass();
                 $image->error = $adapter->getErrors();
                 $images[] = $image;
                 $this->view->data = $images;
             }
         }
     } else {
         throw new Pas_Exception_NotAuthorised('Your account does not seem enabled to do this', 500);
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:83,代码来源:AjaxController.php

示例10: step2Action

 public function step2Action()
 {
     $this->view->messages = $this->_flashMessenger->getMessages();
     $sessionPost = new Zend_Session_Namespace('step1Post');
     if (isset($sessionPost) && $sessionPost != null && isset($sessionPost->formData) && count($sessionPost->formData) > 0) {
         //print_r($sessionPost->formData);
         $step1formData = $sessionPost->formData;
         $formData = array();
         $formErrors = array();
         $formData['business_name'] = $step1formData['business_name'];
         if ($this->getRequest()->isPost()) {
             $formData = $this->getRequest()->getPost();
             //print_r($formData);exit;
             //=====================START FORM VALIDATION===================================
             if (!isset($formData['business_name']) || trim($formData['business_name']) == "") {
                 $formErrors['business_name'] = "Please enter your business name";
             }
             //=====================END FORM VALIDATION===================================
             if (count($formErrors) == 0) {
                 //======inserting data to the candidate table===============
                 $activationCode = CommonFunctions::generateGUID();
                 $activationStartTime = strtotime(date('Y-m-d H:i:s'));
                 $activationExpireTime = strtotime(date('Y-m-d H:i:s', strtotime("+1 days")));
                 //echo "TIME::::".$activationStartTime."====TIME 2:::".strtotime(date('Y-m-d H:i:s'))."===EXPIRE TIME:::".$activationExpireTime;exit;
                 $compData = array('user_name' => $step1formData['user_name'], 'user_email' => $step1formData['user_email'], 'user_password' => $step1formData['user_password'], 'added_date' => date("Y-m-d H:i:s"), 'updated_date' => date("Y-m-d H:i:s"), 'status' => 1, 'activation_code' => $activationCode, 'activation_start_time' => $activationStartTime, 'activation_expire_time' => $activationExpireTime);
                 $lastId = $this->modelCompany->insert($compData);
                 if ($lastId) {
                     //========unset the session for step1 form data====
                     Zend_Session::namespaceUnset('step1Post');
                     //=================================================
                     //======inserting data to the company profile table===============
                     $agree = isset($step1formData['agree']) && $step1formData['agree'] != "" ? 1 : 0;
                     $signup_newsletter = isset($step1formData['signup_newsletter']) && $step1formData['signup_newsletter'] != "" ? 1 : 0;
                     $notify_jobs = isset($step1formData['notify_jobs']) && $step1formData['notify_jobs'] != "" ? 1 : 0;
                     $profileData = array('company_id' => $lastId, 'business_name' => $formData['business_name'], 'contact_name' => $step1formData['contact_name'], 'post_code' => $formData['post_code'], 'state' => $formData['state'], 'industry_1' => $formData['industry_1'], 'industry_2' => $formData['industry_2'], 'about_us' => $formData['about_us'], 'opening_hours' => $formData['opening_hours'], 'telephone' => $formData['telephone'], 'website' => $formData['website'], 'abn' => $formData['abn'], 'acn' => $formData['acn'], 'facebook_url' => $formData['facebook_url'], 'twitter_url' => $formData['twitter_url'], 'shifte_url' => $formData['shifte_url'], 'agree' => $agree, 'signup_newsletter' => $signup_newsletter, 'notify_jobs' => $notify_jobs, 'added_date' => date("Y-m-d H:i:s"), 'updated_date' => date("Y-m-d H:i:s"));
                     $profileId = $this->modelCompanyProfiles->insert($profileData);
                     if ($profileId > 0) {
                         /**** Uploading Logo File on Server*****/
                         $upload = new Zend_File_Transfer_Adapter_Http();
                         $upload->setDestination(COMPANY_UPLOAD_DIR);
                         $files = $upload->getFileInfo();
                         if (isset($files) && count($files) > 0) {
                             $i = 1;
                             foreach ($files as $file => $info) {
                                 if ($info['name'] != "") {
                                     if ($upload->isValid($file)) {
                                         try {
                                             // upload received file(s)
                                             $upload->receive($file);
                                         } catch (Zend_File_Transfer_Exception $e) {
                                             //echo $e->getMessage();//exit;
                                         }
                                         // so, Finally lets See the Data that we received on Form Submit
                                         $name = $upload->getFileName($file);
                                         $size = $upload->getFileSize($file);
                                         # Returns the mimetype for the '$file' form element
                                         $mimeType = $upload->getMimeType($file);
                                         $renameFile = time() . $i . '.jpg';
                                         $fullFilePath = COMPANY_UPLOAD_DIR . $renameFile;
                                         //Rename uploaded file using Zend Framework
                                         $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
                                         $filterFileRename->filter($name);
                                         $logoData = array('logo' => $renameFile);
                                         $this->modelCompanyProfiles->update($logoData, 'id=' . $profileId);
                                     }
                                 }
                                 $i++;
                             }
                         }
                         /*****End Uploading************/
                     }
                     $this->_redirect('company/register/thanks');
                 } else {
                     $this->view->errorMessage = '<div class="div-error">Please enter required fieild to register.</div>';
                 }
             } else {
                 $this->view->errorMessage = '<div class="div-error">Sorry, unable to register, please try later.</div>';
             }
         }
         $this->view->formData = $formData;
         $this->view->formErrors = $formErrors;
         $this->view->industryList = $this->modelIndustries->fetchAll('status=1');
     } else {
         $this->_flashMessenger->addMessage('<div class="div-error">Please enter required fieild to register.</div>');
         $this->_redirect('company/register/');
     }
 }
开发者ID:vmangla,项目名称:evendor,代码行数:87,代码来源:RegisterController_27_feb_2013.php


注:本文中的Zend_File_Transfer_Adapter_Http::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。