當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。