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


PHP qqFileUploader::getFilename方法代码示例

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


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

示例1: admin_add

 /**
  * Upload attachment
  *
  * @return void
  */
 public function admin_add()
 {
     $this->set('title_for_layout', __('Add attachment', true));
     $allowed_extensions = explode(',', Configure::read('Nodeattachment.allowedFileTypes'));
     $size_limit = Configure::read('Nodeattachment.maxFileSize') * 1024 * 1024;
     App::import('Vendor', 'Nodeattachment.file-uploader.php');
     $uploader = new qqFileUploader($allowed_extensions, $size_limit);
     $result = $uploader->handleUpload($this->uploads_path . DS);
     $uploader_file_name = $uploader->getFilename();
     if (isset($this->params['url']['node_id']) && $uploader_file_name != false) {
         $filename['name'] = Inflector::slug($uploader_file_name['filename']);
         $filename['ext'] = $uploader_file_name['ext'];
         $filename = $this->__uniqeSlugableFilename($filename);
         $old_path = $this->uploads_path . DS . $uploader_file_name['filename'] . '.' . $filename['ext'];
         $new_path = $this->uploads_path . DS . $filename['name'] . '.' . $filename['ext'];
         rename($old_path, $new_path);
         $data = array('node_id' => $this->params['url']['node_id'], 'slug' => $filename['name'] . '.' . $filename['ext'], 'path' => '/' . $this->uploads_dir . '/' . $filename['name'] . '.' . $filename['ext'], 'title' => $filename['name'], 'status' => 1, 'mime_type' => $this->__getMime($this->uploads_path . DS . $filename['name'] . '.' . $filename['ext']));
         // get shot time of photo
         if ($data['mime_type'] == 'image/jpeg' || $data['mime_type'] == 'image/tiff') {
             $exif_data = $this->Nodeattachment->getExif($new_path);
             if (isset($exif_data['DateTime'])) {
                 $data['created'] = $exif_data['DateTime'];
             }
         }
         if (!$this->Nodeattachment->save($data)) {
             $result = array('error' => __('The Attachment could not be saved. Please, try again.', true));
         }
     }
     Configure::write('debug', 0);
     $this->disableCache();
     $this->render(false);
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 }
开发者ID:ryansnowden,项目名称:nodeattachment,代码行数:38,代码来源:nodeattachment_controller.php

示例2: admin_add

 /**
  * Upload attachment
  *
  * @return void
  */
 public function admin_add()
 {
     $parentNodeId = $this->request->query['node_id'];
     $allowedExtensions = explode(',', Configure::read('Nodeattachment.allowedFileTypes'));
     $sizeLimit = Configure::read('Nodeattachment.maxFileSize') * 1024 * 1024;
     App::import('Vendor', 'Nodeattachment.fileuploader');
     $Uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $Uploader->handleUpload($this->uploads_path . DS);
     $uploadedFile = $Uploader->getFilename();
     if (isset($parentNodeId) && $uploadedFile != false) {
         $fileName = Inflector::slug($uploadedFile['filename']);
         $fileName .= '.' . $uploadedFile['ext'];
         $fileName = $this->__uniqeSlugableFilename($fileName);
         $uploadPath = $this->uploads_path . DS . $uploadedFile['filename'] . '.' . $uploadedFile['ext'];
         $newPath = $this->uploads_path . DS . $fileName;
         rename($uploadPath, $newPath);
         $data = array('node_id' => $parentNodeId, 'slug' => $fileName, 'path' => '/' . $this->uploads_dir . '/' . $fileName, 'title' => $fileName, 'status' => 1, 'mime_type' => $this->__getMime($newPath));
         // get shot time of photo
         /*if ($data['mime_type'] == 'image/jpeg' || $data['mime_type'] == 'image/tiff') {
                  $exifData = $this->Nodeattachment->getExif($newPath);
                  if (isset($exifData['DateTime']))
                         $data['created'] = $exifData['DateTime'];
           }*/
         if (!$this->Nodeattachment->save($data)) {
             $result = array('success' => false);
         }
     }
     Configure::write('debug', 0);
     $this->disableCache();
     $this->render(false);
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 }
开发者ID:elcuro,项目名称:nodeattachment,代码行数:37,代码来源:NodeattachmentController.php


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