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


PHP Zend_File_Transfer_Adapter_Http::hasErrors方法代码示例

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


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

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


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