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


PHP UploadHandler::delete方法代码示例

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


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

示例1: upload

 public function upload()
 {
     $this->load->library('replay');
     error_reporting(E_ALL | E_STRICT);
     $this->load->helper("upload.class");
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             break;
         case 'POST':
             if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $upload_handler->post();
             }
             break;
         case 'DELETE':
             $upload_handler->delete();
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
开发者ID:rabbitXIII,项目名称:FFAReplays,代码行数:34,代码来源:uploader.php

示例2: handle

 public function handle()
 {
     // required upload handler helper
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'uploadhandler.php';
     $userId = JFactory::getUser()->id;
     $session = JFactory::getSession();
     $sessionId = $session->getId();
     // make dir
     $tmpImagesDir = JPATH_ROOT . DS . 'tmp' . DS . $userId . DS . $sessionId . DS;
     $tmpUrl = 'tmp/' . $userId . '/' . $sessionId . '/';
     // unlink before create
     @unlink($tmpImagesDir);
     // create folder
     @mkdir($tmpImagesDir, 0777, true);
     $uploadOptions = array('upload_dir' => $tmpImagesDir, 'upload_url' => $tmpUrl, 'script_url' => JRoute::_('index.php?option=com_ntrip&task=uploadfile.handle', false));
     $uploadHandler = new UploadHandler($uploadOptions, false);
     //	$session->set('files', null);
     $files = $session->get('files', array());
     if ($session->get('request_method') == 'delete') {
         $fileDelete = $uploadHandler->delete(false);
         // search file
         $key = array_search($fileDelete, $files);
         // unset in $files
         unset($files[$key]);
         $session->set('files', $files);
         $session->set('request_method', null);
         exit;
     }
     if ($_POST) {
         $file = $uploadHandler->post();
         $files[] = $file;
         $session->set('files', $files);
     }
     exit;
 }
开发者ID:ngxuanmui,项目名称:hp3,代码行数:35,代码来源:uploadfile.php

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

示例4: delete

 public function delete($print_response = true)
 {
     $response = parent::delete(false);
     foreach ($response as $name => $deleted) {
         if ($deleted) {
             $sql = 'DELETE FROM `' . $this->options['db_table'] . '` WHERE `name`=?';
             $query = $this->db->prepare($sql);
             $query->bind_param('s', $name);
             $query->execute();
         }
     }
     return $this->generate_response($response, $print_response);
 }
开发者ID:cruni505,项目名称:prestomed,代码行数:13,代码来源:maraton_eqganador.php

示例5: UploadHandler

require_once "../../includes/initialize.php";
global $session;
$group = Group::get_by_id($session->user_group_id);
$upload_handler = new UploadHandler($group, "questions");
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-Disposition: inline; filename="files.json"');
header('X-Content-Type-Options: nosniff');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
switch ($_SERVER['REQUEST_METHOD']) {
    case 'OPTIONS':
        break;
    case 'HEAD':
    case 'GET':
        $upload_handler->get();
        break;
    case 'POST':
        if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
            $upload_handler->delete();
        } else {
            $upload_handler->post();
        }
        break;
    case 'DELETE':
        $upload_handler->delete();
        break;
    default:
        header('HTTP/1.1 405 Method Not Allowed');
}
开发者ID:NemOry,项目名称:BundledFunWebPanel,代码行数:31,代码来源:question_uploader.php

示例6: processImage

 public function processImage($template_id)
 {
     if (empty($template_id)) {
         return;
     }
     $this->CI->load->helper("upload");
     $path = UPLOAD_PATH . '../template/';
     $config['upload_dir'] = $path;
     $config['upload_dir'] = $config['upload_dir'];
     if (!is_dir($config['upload_dir'])) {
         //create the folder if it's not already exists
         mkdir($config['upload_dir'], 0755, TRUE);
     }
     $config['script_url'] = base_url() . $path;
     $config['upload_url'] = base_url() . $path;
     $upload_handler = new UploadHandler($config);
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             //$id_template= $template_id;
             $upload_dir = dirname($_SERVER['SCRIPT_FILENAME']) . $path;
             $url = base_url();
             $files = array();
             $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "FRONT";
             //echo $type;
             if ($images = $this->CI->template_m->get_images($template_id, $type)) {
                 foreach ($images as $img) {
                     $returnpath = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                     if (file_exists($returnpath)) {
                         $file = new stdClass();
                         $file->name = $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->id_image = $img->id_image;
                         $file->url = $path . $template_id . '_' . $img->id_image . $this->img_extension;
                         $file->delete_url = site_url() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($img->id_image) . '&&id_template=' . rawurlencode($template_id);
                         $file->delete_url .= '&&method=DELETE';
                         $file->deleteType = 'DELETE';
                         $file->url_default = site_url() . '/admin/template/set_default/' . $template_id . '/' . $img->id_image . '/' . $img->type;
                         $files[] = $file;
                     }
                 }
             }
             $obj = new stdClass();
             $obj->files = $files;
             ob_clean();
             print_r(json_encode($obj));
             ob_flush();
             break;
         case 'POST':
             if (isset($_REQUEST['method']) && $_REQUEST['method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $id_template = $template_id;
                 $type = $this->CI->input->post('type') ? $this->CI->input->post('type') : "FRONT";
                 //parent::create($this->fields);
                 if (isset($_FILES['files'])) {
                     if ($timage = $this->CI->template_m->createimage($template_id, $type)) {
                         $new_file_path = $path . $id_template . "_" . $timage->id_image . $this->img_extension;
                         if (isset($_FILES['files']['tmp_name'][0])) {
                             $file_path = $_FILES['files']['tmp_name'][0];
                             if (file_exists($file_path)) {
                                 if ($file_path !== $new_file_path) {
                                     //	 @copy($file_path, $new_file_path);
                                     $config['image_library'] = 'gd2';
                                     $config['source_image'] = $file_path;
                                     $config['new_image'] = $new_file_path;
                                     $config['maintain_ratio'] = TRUE;
                                     $config['height'] = MAX_TEMPLATE_HEIGHT;
                                     $this->CI->load->library('image_lib');
                                     $resizer = new CI_Image_lib();
                                     $resizer->initialize($config);
                                     $resizer->resize();
                                 }
                             }
                         }
                     }
                     $files_return = array();
                     //     foreach ($images as $img) {
                     $file = new stdClass();
                     $file->name = $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->id_image = $timage->id_image;
                     $file->url = $path . $id_template . '_' . $timage->id_image . $this->img_extension;
                     $file->delete_url = $this->getFullUrl() . '/admin/template/img_upload' . '?id_image=' . rawurlencode($timage->id_image) . '&&id_template=' . rawurlencode($id_template);
                     $file->delete_url .= '&&method=DELETE';
                     $file->deleteType = 'DELETE';
                     $file->url_default = site_url() . '/admin/template/set_default/' . $id_template . '/' . $timage->id_image . '/' . $type;
                     $files_return[] = $file;
                     //  };
                     $object = new stdClass();
                     $object->files = $files_return;
                     ob_clean();
                     print_r(json_encode($object));
//.........这里部分代码省略.........
开发者ID:nockout,项目名称:tshpro,代码行数:101,代码来源:Tplate.php

示例7: delete

 /**
  * We should remove the unused directory after deleting a file
  */
 public function delete()
 {
     parent::delete();
     $dir = $this->options['upload_dir'];
     // Check that the upload dir has no files in it
     $empty = true;
     foreach (glob("{$dir}/*") as $item) {
         if (is_file($item)) {
             $empty = false;
         }
     }
     // There are no uploaded files in this directory, nuke it
     // - we need to use rm -rf because it still contains sub-dirs and meta data
     if ($empty) {
         exec("rm -rf {$dir}");
     }
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:20,代码来源:MWUploadHandler.php

示例8: delete

 public function delete($print_response = true)
 {
     $response = parent::delete(false);
     $mapper = Core::model('Core/Attachment');
     foreach ($response as $code => $deleted) {
         if ($deleted) {
             $mapper->deleteByCode($code);
         }
     }
     //exit;
     return $this->generate_response($response, $print_response);
 }
开发者ID:phucdnict,项目名称:cbcc_05062015,代码行数:12,代码来源:index.php

示例9: uploadHandler

 private function uploadHandler()
 {
     #$script_dir = Yii::app()->basePath.'/data/p3media';
     #$script_dir_url = Yii::app()->baseUrl;
     $options = array('url' => $this->createUrl("/p3media/p3Media/update", array('path' => Yii::app()->user->id . "/")), 'upload_dir' => $this->module->getDataPath() . DIRECTORY_SEPARATOR, 'upload_url' => $this->createUrl("/p3media/p3Media/update", array('preset' => 'raw', 'path' => Yii::app()->user->id . "/")), 'script_url' => $this->createUrl("/p3media/import/uploadFile", array('path' => Yii::app()->user->id . "/")), 'field_name' => 'files', 'image_versions' => array('thumbnail' => array('upload_url' => $this->createUrl("/p3media/file/image", array('preset' => 'p3media-upload', 'path' => urlencode(Yii::app()->user->id . "/"))), 'max_width' => 80, 'max_height' => 80)));
     // wrapper for jQuery-file-upload/upload.php
     $upload_handler = new UploadHandler($options);
     header('Pragma: no-cache');
     header('Cache-Control: private, no-cache');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     ob_start();
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             #$contents = ob_get_contents();
             $contents = "{}";
             // we do not show existing files, since this list may get very long
             break;
         case 'POST':
             // check if file exists
             $upload = $_FILES[$options['field_name']];
             $tmp_name = $_FILES[$options['field_name']]['tmp_name'];
             if (is_array($tmp_name)) {
                 foreach ($tmp_name as $index => $value) {
                     $model = P3Media::model()->findByAttributes(array('path' => Yii::app()->user->id . DIRECTORY_SEPARATOR . $upload['name'][$index]));
                     $model = new P3Media();
                     $attributes['path'] = Yii::app()->user->id . DIRECTORY_SEPARATOR . $upload['name'][$index];
                     #$attributes['title'] = $upload['name'][$index]; // TODO: fix title unique check
                     #var_dump($attributes['title']);exit;
                     $model->attributes = $attributes;
                     $model->validate(array('path'));
                     if ($model->hasErrors()) {
                         #throw new CHttpException(500, 'File exists.');
                         $file = new stdClass();
                         $file->error = "";
                         foreach ($model->getErrors() as $error) {
                             $file->error .= $error[0];
                         }
                         $info[] = $file;
                         echo CJSON::encode($info);
                         exit;
                     }
                 }
             }
             $upload_handler->post();
             $upload_handler_output = ob_get_contents();
             $result = CJSON::decode($upload_handler_output);
             #var_dump($result);exit;
             $savedMedia = $this->createMedia($result[0]['name'], $this->module->getDataPath() . DIRECTORY_SEPARATOR . $result[0]['name']);
             $result[0]['p3_media_id'] = $savedMedia->id;
             $contents = CJSON::encode($result);
             break;
         case 'DELETE':
             $upload_handler->delete();
             $contents = ob_get_contents();
             $result = $this->deleteMedia($_GET['path']);
             break;
         default:
             header('HTTP/1.0 405 Method Not Allowed');
             $contents = ob_get_contents();
     }
     ob_end_clean();
     return $contents;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:66,代码来源:ImportController.php

示例10: delete

 public function delete($print_response = true)
 {
     if (PWEBCONTACT_DEBUG) {
         modPwebcontactHelper::setLog('Deleting file');
     }
     return parent::delete($print_response);
 }
开发者ID:01J,项目名称:topm,代码行数:7,代码来源:uploader.php

示例11: upload

 public function upload()
 {
     $_user = $this->uri->segment(1);
     $_details = $this->mFrontend->getDetailsbyURL($_user);
     if ($_details != false) {
         if ($_details->userCanUpload == '0') {
             exit;
         }
     } else {
         exit;
     }
     $this->load->helper("upload.class");
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Vary: accept');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             $upload_handler->get();
             break;
         case 'POST':
             if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
                 $upload_handler->delete();
             } else {
                 $upload_handler->post();
             }
             break;
         case 'DELETE':
             $upload_handler->delete();
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:42,代码来源:frontend.php

示例12: uploadAction

 public function uploadAction()
 {
     if ($this->getRequest()->isPost()) {
         $upload_handler = new UploadHandler();
         header('Pragma: no-cache');
         header('Cache-Control: no-store, no-cache, must-revalidate');
         header('Content-Disposition: inline; filename="files.json"');
         header('X-Content-Type-Options: nosniff');
         header('Access-Control-Allow-Origin: *');
         header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
         header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'OPTIONS':
                 break;
             case 'HEAD':
             case 'GET':
                 $upload_handler->get();
                 break;
             case 'POST':
                 if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
                     $upload_handler->delete();
                 } else {
                     $info = $upload_handler->post();
                     $this->_helper->json($info, true, false);
                 }
                 break;
             case 'DELETE':
                 $upload_handler->delete();
                 break;
             default:
                 header('HTTP/1.1 405 Method Not Allowed');
         }
     }
 }
开发者ID:nldfr219,项目名称:zhi,代码行数:34,代码来源:ProfileController.php

示例13: _loader

 public function _loader()
 {
     $upload_handler = new UploadHandler();
     header('Pragma: no-cache');
     header('Cache-Control: private, no-cache');
     header('Content-Disposition: inline; filename="files.json"');
     header('X-Content-Type-Options: nosniff');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
     header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
     //$fp=fopen("log.txt","w");
     //fwrite($fp,"QUEST:".$_POST["upselect"]);
     //fclose($fp);
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'OPTIONS':
             break;
         case 'HEAD':
         case 'GET':
             /*$fp=fopen("log.txt","w");
               fwrite($fp,"QUEST:".$_GET["name"]); 
               fclose($fp);*/
             $upload_handler->get($_GET["name"]);
             break;
         case 'POST':
             $upload_handler->post();
             //写入数据库。其中imagegroupID从$_POST["upselect"]得到,imageurl从$upload_handler->filepathout得到。
             if (!$upload_handler->error) {
                 $name = $upload_handler->name;
                 $url = $upload_handler->filepathout;
                 $fp = fopen("log.txt", "a");
                 fwrite($fp, "NEW:" . $url . "\r\n");
                 fclose($fp);
                 $groupID = $_POST["upselect"];
                 $imgmd = new image();
                 $data = array($name, "", $_SESSION["USERID"], date("Y-m-d"), $url, $groupID, '', '');
                 $imgmd->model->New($data);
                 $act = new active();
                 $img = new stdClass();
                 $img->gid = $groupID;
                 $img->d = $url;
                 $img->ti = time();
                 $img->gn = "xxxx";
                 $act->_new($_SESSION["USERID"], 1, $img);
             }
             break;
         case 'DELETE':
             $upload_handler->delete();
             $file_name = isset($_REQUEST['file']) ? basename(stripslashes($_REQUEST['file'])) : null;
             $url = $file_name;
             $imgmd = new image();
             $imgmd->model->Del_By_imgurl($file_name);
             $act = new active();
             $img = new stdClass();
             $img->d = $url;
             $img->ti = time();
             $act->_del($_SESSION['USERID'], $img);
             break;
         default:
             header('HTTP/1.1 405 Method Not Allowed');
     }
 }
开发者ID:RaoHai,项目名称:picpic,代码行数:61,代码来源:controller.user.class.php


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