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


PHP UploadHandler::head方法代码示例

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


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

示例1: upload

 public function upload($config = 'default')
 {
     if (!$this->request->is(array('post', 'put', 'delete'))) {
         die('Method not allowed');
     }
     App::import('Vendor', 'BlueUpload.UploadHandler', array('file' => 'UploadHandler.php'));
     $options = Configure::read("BlueUpload.options.{$config}");
     $upload_handler = new UploadHandler($options, $initialize = false);
     if ($this->request->is(array('post', 'put'))) {
         $content = $upload_handler->post($print_response = false);
         // save into uploads table
         foreach ($content['files'] as &$file) {
             if (!isset($file->error)) {
                 $upload = array('name' => $file->name, 'size' => $file->size, 'type' => $file->type, 'url' => $file->url, 'dir' => $options['upload_dir'], 'deleteUrl' => $file->deleteUrl, 'deleteType' => $file->deleteType);
                 // 'thumbnailUrl' => $file->thumbnailUrl,
                 // 'previewUrl'   => $file->previewUrl,
                 //  ... etc
                 if (isset($options['image_versions'])) {
                     foreach ($options['image_versions'] as $version_name => $version) {
                         if (!empty($version_name)) {
                             $upload[$version_name . 'Url'] = $file->{$version_name . 'Url'};
                         }
                     }
                 }
                 // invoke a custom event so app can mangle the data
                 $event = new CakeEvent('Model.BlueUpload.beforeSave', $this, array('upload' => $upload));
                 $this->Upload->getEventManager()->dispatch($event);
                 if ($event->isStopped()) {
                     continue;
                 }
                 // pickup mangled data
                 if (!empty($event->result['upload'])) {
                     $upload = $event->result['upload'];
                 }
                 $this->Upload->create();
                 $this->Upload->save($upload);
                 $file->id = $this->Upload->getLastInsertID();
                 unset($file->deleteUrl);
                 unset($file->deleteType);
                 // account for apps installed in subdir of webroot
                 $file->url = Router::url($file->url);
                 if (isset($file->thumbnailUrl)) {
                     $file->thumbnailUrl = Router::url($file->thumbnailUrl);
                 }
             }
         }
     } else {
         if ($this->request->is(array('delete'))) {
             $content = $upload_handler->delete($print_response = false);
             // delete from uploads table
             foreach ($content['files'] as &$file) {
             }
         }
     }
     $json = json_encode($content);
     $upload_handler->head();
     echo $json;
     $this->autoRender = false;
 }
开发者ID:ptica,项目名称:BlueUpload,代码行数:59,代码来源:BlueUploadController.php


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