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


PHP Zend_File_Transfer_Adapter_Http::getFileSize方法代码示例

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


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

示例1: 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;
     }
 }
开发者ID:nandorodpires2,项目名称:gallery,代码行数:22,代码来源:UploadHash.php

示例2: 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

示例3: basicProfileSave


//.........这里部分代码省略.........
         } catch (Zend_File_Transfer_Exception $e) {
             $this->message = $e->getMessage();
         }
         if (empty($this->message)) {
             //If there is no error message then try saving to amazon s3
             // save images to amazon s3
             global $app;
             $aws_key = null;
             $aws_secret_key = null;
             $aws_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_key']['value'];
             $aws_secret_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_secret']['value'];
             $amazon_bucket_name = $app->configData['configuration']['api_keys']['value']['amazon_s3_bucket']['value'];
             if (isset($aws_key) && isset($aws_secret_key)) {
                 $s3 = null;
                 $bucketAvailable = false;
                 $bucketCreated = false;
                 $s3 = new Zend_Service_Amazon_S3($aws_key, $aws_secret_key);
                 if (isset($s3)) {
                     $bucketCreated = false;
                     $bucketAvailable = $s3->isBucketAvailable($amazon_bucket_name);
                     if (!$bucketAvailable) {
                         if ($s3->createBucket($amazon_bucket_name)) {
                             // new bucket was created
                             $bucketCreated = true;
                         }
                     } else {
                         $bucketCreated = true;
                     }
                     if ($bucketCreated == true) {
                         // delete old amazon s3 pictures
                         $this->handleDeleteUserPic($request_data);
                         $file_path = $zendUploadAdapter->getFileName('userfile', true);
                         $file_name = $zendUploadAdapter->getFileName('userfile', false);
                         $file_size = $zendUploadAdapter->getFileSize('userfile');
                         $file_name = $this->cleanupFileName($file_name);
                         $file_info = getimagesize($file_path);
                         $file_mime_type = isset($file_info) && isset($file_info['mime']) && !empty($file_info['mime']) ? $file_info['mime'] : null;
                         $apiDataArray['person'] = array('avatar' => array('file_name' => $file_name, 'content_type' => $file_mime_type, 'file_size' => $file_size));
                         // api_call needs to be set to true in order for the User class to update the avatar and avatar_small fields
                         $this->user_info->api_call = true;
                         foreach ($this->_image_sizes as $imageSizeType => $imageDimensions) {
                             // Resize image into thumbnails
                             $imageAsString = null;
                             try {
                                 $thumb = PhpThumbFactory::create($file_path);
                                 if (!isset($this->user_info->core_id) && !empty($this->user_info->core_id)) {
                                     $this->user_info->core_id = 0;
                                 }
                                 $objectPath = $this->buildAmazonS3ObjectURL($imageSizeType, $this->user_info->core_id, $file_name);
                                 if (isset($imageDimensions) && !empty($imageDimensions)) {
                                     // if this is an original size image, the width and height dont need to be set
                                     $thumb->adaptiveResize($imageDimensions['width'], $imageDimensions['height']);
                                 }
                                 $imageAsString = $thumb->getImageAsString();
                                 $amazonURL = "http://s3.amazonaws.com/" . $amazon_bucket_name;
                                 switch ($imageSizeType) {
                                     case "large":
                                         $this->user_info->picture = $objectPath;
                                         $this->user_info->picture_dimensions = $imageDimensions;
                                         break;
                                     case "standard":
                                         $this->user_info->avatar = $objectPath;
                                         $this->user_info->avatar_dimensions = $imageDimensions;
                                         break;
                                     case "medium":
                                         $this->user_info->avatar_small = $objectPath;
开发者ID:CivicCommons,项目名称:people-aggregator,代码行数:67,代码来源:EditProfileModule.php

示例4: addAction

 /** Add a new image
  */
 public function addAction()
 {
     $form = new ImageForm();
     $form->submit->setLabel('Submit a new image.');
     $user = $this->getUserDetails();
     $username = $user['username'];
     if (is_dir(self::PATH . $username)) {
         $form->image->setDestination(self::PATH . $username);
     } else {
         $path = mkdir(self::PATH . $username);
         $form->image->setDestination($path);
     }
     $this->view->form = $form;
     $savePath = self::PATH . $username . '/medium/';
     $thumbPath = self::PATH . 'thumbnails/';
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         $upload = new Zend_File_Transfer_Adapter_Http();
         if ($form->isValid($formData)) {
             $upload = new Zend_File_Transfer_Adapter_Http();
             $upload->addValidator('NotExists', false, array(self::PATH . $username));
             $filesize = $upload->getFileSize();
             if ($upload->isValid()) {
                 $filename = $form->getValue('image');
                 $label = $formData['label'];
                 $secuid = $this->secuid();
                 $insertData = array();
                 $insertData['filename'] = $filename;
                 $insertData['label'] = $label;
                 $insertData['county'] = $form->getValue('county');
                 $insertData['period'] = $form->getValue('period');
                 $insertData['filedate'] = $this->getTimeForForms();
                 $insertData['created'] = $this->getTimeForForms();
                 $insertData['createdBy'] = $this->getIdentityForForms();
                 $insertData['filesize'] = $filesize;
                 $insertData['imagerights'] = $form->getValue('copyrighttext');
                 $insertData['secuid'] = $secuid;
                 //$insertData['mimetype'] = $mimetype;
                 foreach ($insertData as $key => $value) {
                     if (is_null($value) || $value == "") {
                         unset($insertData[$key]);
                     }
                 }
                 $upload->receive();
                 $location = self::PATH . $username . '/' . $filename;
                 $id = $this->_images->insert($insertData);
                 //Update the solr instance
                 $this->_helper->solrUpdater->update('beoimages', $id);
                 $largepath = self::PATH . $username . '/';
                 $mediumpath = self::PATH . $username . '/medium/';
                 $smallpath = self::PATH . $username . '/small/';
                 $displaypath = self::PATH . $username . '/display/';
                 $thumbpath = self::PATH . 'thumbnails/';
                 $name = substr($filename, 0, strrpos($filename, '.'));
                 $ext = '.jpg';
                 //create medium size
                 $phMagick = new phMagick($location, $mediumpath . $name . $ext);
                 $phMagick->resize(500, 0);
                 $phMagick->convert();
                 //Very small size
                 $phMagick = new phMagick($location, $smallpath . $name . $ext);
                 $phMagick->resize(40, 0);
                 $phMagick->convert();
                 //Record display size
                 $phMagick = new phMagick($location, $displaypath . $name . $ext);
                 $phMagick->resize(0, 150);
                 $phMagick->convert();
                 //Thumbnail size
                 $phMagick = new phMagick($location, $thumbpath . $id . $ext);
                 $phMagick->resize(100, 100);
                 $phMagick->convert();
                 $linkData = array();
                 $linkData['find_id'] = $this->_getParam('findID');
                 $linkData['image_id'] = $secuid;
                 $linkData['secuid'] = $this->secuid();
                 $imagelink = new FindsImages();
                 $insertedlink = $imagelink->insert($linkData);
                 $this->_cache->remove('findtoimage' . $this->_getParam('id'));
                 $this->_flashMessenger->addMessage('The image has been resized and added!');
                 $this->_redirect('/database/artefacts/record/id/' . $this->_getParam('id'));
             } else {
                 $this->_flashMessenger->addMessage('There is a problem with your upload. Probably that image exists.');
                 $this->view->errors = $upload->getMessages();
             }
         } else {
             $form->populate($form->getValues());
             $this->_flashMessenger->addMessage('Check your form for errors dude');
         }
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:92,代码来源:ImagesController.php

示例5: cargararchivoAction

 public function cargararchivoAction()
 {
     $idcurso = $this->_request->idcurso;
     $iddocpadre = $this->_request->iddocpadre;
     $titulo = $this->getRequest()->getParam('txtnombre');
     $documento = new Application_Model_Documentos();
     $ruta = $documento->obternerruta($iddocpadre);
     $upload = new Zend_File_Transfer_Adapter_Http();
     //        $upload = new Zend_File_Transfer();
     $upload->addValidator('FilesSize', false, array('min' => '10kB', 'max' => '4MB'));
     //$upload->addValidator('Extension', false, 'jpg,png,pdf');
     $upload->setDestination("main/documentos/" . $idcurso . $ruta);
     try {
         // upload received file(s)
         $name = $upload->getFileName('filee');
         $tamano = $upload->getFileSize('filee');
         $accion = $documento->buscarNombreArchivobyIdDocuPadre($iddocpadre, $titulo);
         if ($accion == 0) {
             $documento->registrarArchivo($idcurso, NULL, $name, NULL, $titulo, $iddocpadre, $tamano);
             $upload->receive();
         } else {
             return $this->_redirect("http://www.google.com");
         }
         //             $extension = pathinfo($name, PATHINFO_EXTENSION);
         //
         //             $renameFile = $idusuario.'.'.$extension;
         //             $fullFilePath = 'main/'.$renameFile;
         //             $fullFilePath = 'main/'.$name;
         // Rename uploaded file using Zend Framework
         //             $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
         //             $filterFileRename -> filter($name);
         //             $usuario->actualizarFoto($idusuario, $fullFilePath);
     } catch (Zend_File_Transfer_Exception $e) {
         return $this->_redirect("http://www.google.com");
     }
     return $this->_redirect('docente/documentos?idcurso=' . $idcurso . '&iddocpadre=' . $iddocpadre);
 }
开发者ID:renzot23,项目名称:Los-Pinos-Virtual,代码行数:37,代码来源:DocenteController.php

示例6: 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

示例7: shp2jsonAction

 /**
  * convert a shapefile to geojson
  */
 public function shp2jsonAction()
 {
     $dataType = $this->_request->getParam('dataType');
     $response = array();
     // name for the temporary directory -- initializing the variable
     $import_tmpdir = Null;
     try {
         // get all needed config values
         $config = Zend_Registry::get("config");
         if (empty($config->path->ogr2ogr)) {
             throw new Ole_ProcessController_MissingConfigException("ogr2ogr is not configured");
         }
         $ogr2ogr_path = $config->path->ogr2ogr;
         if (empty($config->directory->tmp)) {
             throw new Ole_ProcessController_MissingConfigException("the temporary directory is not configured");
         }
         $tmpdir_path = $config->directory->tmp;
         // build the name for the temp dir for this upload
         $import_tmpdir = rtrim($tmpdir_path, '/') . "/shpimport_" . md5(time() . rand());
         mkdir($import_tmpdir);
         // prepare the filetransfer
         $filetransfer = new Zend_File_Transfer_Adapter_Http();
         $filetransfer->setDestination($import_tmpdir);
         $filetransfer->receive();
         if (!$filetransfer->isUploaded("shp")) {
             throw new Ole_ProcessController_MissingUploadException();
         }
         // limit the upload size
         if ($filetransfer->getFileSize('shp') >= 204800) {
             throw new Ole_ProcessController_UploadSizeException();
         }
         // extract the shapefile
         $shp_name = $this->extractShape($filetransfer->getFileName('shp'), $import_tmpdir);
         if (empty($shp_name)) {
             throw new Ole_ProcessController_MissingUploadException("the zipfile does not seem to contain a shapefile");
         }
         // read shapefile
         $response["geo"] = $this->shapeToGeojson($shp_name, $ogr2ogr_path, $import_tmpdir);
         $response["success"] = True;
         $response["msg"] = "Shapefile successfully uploaded";
     } catch (Ole_ProcessController_MissingConfigException $e) {
         $response["success"] = False;
         $response["msg"] = "Missing Configuration : " . $e->getMessage();
     } catch (Ole_ProcessController_MissingUploadException $e) {
         $response["success"] = False;
         $response["msg"] = "No shapefile uploaded :" . $e->getMessage();
     } catch (Ole_ProcessController_UploadSizeException $e) {
         $response["success"] = False;
         $response["msg"] = "the shapefile uploaded is too big";
     } catch (Ole_ProcessController_ZipException $e) {
         $response["success"] = False;
         $response["msg"] = "error opening zipfile : " . $e->getMessage();
     } catch (Ole_ProcessController_ShapeToGeojsonException $e) {
         $response["success"] = False;
         $response["msg"] = "error reading the shapefile : " . $e->getMessage();
     }
     // remove the temporary files. they will not get removed on uncaught exceptions
     // because PHP lacks a finally block
     if (!empty($import_tmpdir)) {
         $this->recursiveRmDir($import_tmpdir);
     }
     // send html to enable ajax upload
     if ($dataType == 'html') {
         // View contains an empty HTML page as layout
         $this->getHelper('Layout')->disableLayout();
         $this->view->assign('response', $response);
     } else {
         $this->getHelper('Json')->sendJson($response);
     }
 }
开发者ID:neolf,项目名称:ole,代码行数:73,代码来源:ProcessController.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: array

<?php

// creating the File_Transfer instance (with Http Adapter)
$upload = new Zend_File_Transfer_Adapter_Http();
//	firelog($upload->getFileInfo());
// setting the destination
$UPLOAD_DIR = $_POST['path'];
$upload->setDestination($UPLOAD_DIR);
// adding some validators
//$upload->addValidator('Extension', false, 'csv');*/
// uploading the file if valid
if ($upload->isValid()) {
    try {
        $upload->addFilter('Rename', array('target' => $UPLOAD_DIR . '/' . $upload->getFileName(null, false)));
        $upload->receive();
        if ($upload->isReceived()) {
            $return = array('success' => true, 'message' => 'SUCESS: ' . $upload->getFileName(null, false) . '(' . $upload->getFileSize() . ')');
        } else {
            $return = array('success' => false, 'error' => 'ERROR: File Not Received');
        }
    } catch (Exception $e) {
        $return = array('success' => false, 'error' => 'ERROR: Upload Failure');
    }
} else {
    $return = array('success' => false, 'error' => 'ERROR: File not valid');
}
echo Zend_Json::encode($return);
开发者ID:sanmas,项目名称:ExtJs-FileExplorer,代码行数:27,代码来源:upload-request.php

示例10: 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

示例11: 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

示例12: uploadformAction

 public function uploadformAction()
 {
     try {
         $this->view->maxFileZise = 9000000;
         $request = $this->getRequest();
         $fileDescription = $request->getParam('file_description', '');
         $this->_folder = $request->getParam('folder', 'all');
         //echo $_SERVER ['DOCUMENT_ROOT'];
         if ($request->getPost()) {
             $folder = 'files';
             $targetPath = UPLOAD_PATH . '/' . $folder . '/' . $this->_folder . '/';
             //echo $targetPath;
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $adapter->setDestination($targetPath);
             if (!$adapter->isValid()) {
                 throw new Exception('Bad file data: ' . implode(',', $adapter->getMessages()));
             }
             $filePath = $adapter->getFileName();
             $fileSize = $adapter->getFileSize();
             $fileInfo = pathinfo($filePath);
             $fileExtension = $fileInfo['extension'];
             $fileNameUTF = basename($filePath, '.' . $fileExtension);
             $fileName = iconv("UTF-8", "TIS-620", $fileNameUTF);
             $fileUrl = '/' . $folder . '/' . $this->_folder . '/' . $fileName . '.' . $fileExtension;
             $thumbnailName = $fileName . '_thumbnails' . '.' . $fileExtension;
             $thumbnailUrl = "/files/" . $this->_folder . '/' . $thumbnailName;
             $renamePath = $targetPath . $fileName . '.' . $fileExtension;
             $adapter->addFilter('Rename', $renamePath);
             //$fileName = uniqid ();
             if ($this->isBadFile($fileExtension)) {
                 throw new Exception('Bad file type  : not accept \'' . $fileExtension . '\'');
             }
             $file = new Cms_Model_File();
             $result = $file->fetchAll("name='{$fileNameUTF}' AND folder='{$this->_folder}'");
             if (count($result) > 0) {
                 $this->_setWarning('Duplicate file name :' . $fileNameUTF);
                 throw new Exception('Duplicate file name :' . $fileNameUTF);
             }
             $file = new Cms_Model_File();
             $fileNameUTF = iconv("TIS-620", "UTF-8", $fileName);
             $fileUrlUTF = iconv("TIS-620", "UTF-8", $fileUrl);
             $file->setName($fileNameUTF)->setPath($fileUrlUTF)->setType($fileExtension)->setDescription($fileDescription);
             if ($this->_folder != 'all') {
                 $file->setFolder($this->_folder);
             }
             $file->setCreated(new DateTime());
             $file->setCreatedBy(Sam_Auth::getInstance()->getUser()->getId());
             $adapter->receive();
             if ($this->isImage($fileExtension)) {
                 $this->rezise($renamePath, $targetPath, $thumbnailName);
                 $thumbnailUrlUTF = iconv("TIS-620", "UTF-8", $thumbnailUrl);
                 $file->setThumbnailPath($thumbnailUrlUTF);
             }
             $file->save();
             $this->view->layout()->infocode = 22;
         }
     } catch (Zend_File_Transfer_Exception $e) {
         $this->_setWarning($e->getMessage() . $targetPath);
         //throw new Exception ( 'Bad file data: ' . $e->getMessage () );
     } catch (Exception $e) {
         $this->_setWarning($e->getMessage());
         //throw new Exception ( 'Bad file data: ' . $e->getMessage () );
     }
 }
开发者ID:hugi2002,项目名称:mylibrary,代码行数:64,代码来源:FileOldController.php

示例13: addrulerimageAction

 /** Add an image for a ruler
  * @access public
  * @return void
  */
 public function addrulerimageAction()
 {
     $form = new AddRulerImageForm();
     $form->rulerID->setValue($this->getParam('rulerid'));
     $form->submit->setLabel('Add an image for a ruler');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $upload = new Zend_File_Transfer_Adapter_Http();
             $upload->addValidator('NotExists', false, array('./assets/rulers/'));
             $filesize = $upload->getFileSize();
             if ($upload->isValid()) {
                 $filename = $form->getValue('image');
                 $insertData = $form->getValues();
                 $insertData['filesize'] = $filesize;
                 $rulers = new RulerImages();
                 $upload->receive();
                 $rulers->add($insertData);
                 $this->getFlash()->addMessage('The image has been resized.');
                 $this->redirect($this->_redirectUrl . 'romanruler/id/' . $this->getParam('rulerid'));
             } else {
                 $this->getFlash()->addMessage('There is a problem with your upload.Probably that image exists.');
                 $this->view->errors = $upload->getMessages();
             }
         } else {
             $this->getFlash()->addMessage($this->_formErrors);
             $form->populate($formData);
         }
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:35,代码来源:NumismaticsController.php


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