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


PHP upload::file方法代码示例

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


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

示例1: files

 /**
  * Function to upload multi file
  * 
  * @param string 	$field			Field name to upload
  * @param string 	$uploadPath		Path to upload
  * @param boolean 	$thumb			Auto generate thumbnail or not
  * @param string 	$thumbName		If auto generate, this will be used for thumbnail
  */
 function files($field, $uploadPath, $newName = null, $thumb = false, $uploadPathThumbs = null, $thumbName = null)
 {
     $files = JRequest::get('files');
     $arrFiles = array();
     //rebuild array to re-use function upload::file
     foreach ($files['jform']['error'][$field] as $key => $error) {
         if (!$error) {
             $arrFiles[$key]['jform']['name'][$field] = $files['jform']['name'][$field][$key];
             $arrFiles[$key]['jform']['type'][$field] = $files['jform']['type'][$field][$key];
             $arrFiles[$key]['jform']['tmp_name'][$field] = $files['jform']['tmp_name'][$field][$key];
             $arrFiles[$key]['jform']['error'][$field] = $files['jform']['error'][$field][$key];
             $arrFiles[$key]['jform']['size'][$field] = $files['jform']['size'][$field][$key];
         }
     }
     $result = array();
     $i = 1;
     foreach ($arrFiles as $key => $file) {
         if ($newName) {
             $newName = $i . '-' . $newName;
         }
         $i++;
         $result[$key] = upload::file($file['jform'], $field, $uploadPath, $newName, $thumb, $uploadPathThumbs, $thumbName);
     }
     return $result;
 }
开发者ID:ngxuanmui,项目名称:hp3,代码行数:33,代码来源:upload.class.php

示例2: editFont

 public function editFont($id = '')
 {
     $file = dirname(ROOT) . DS . 'data' . DS . 'fonts.json';
     include_once ROOT . DS . 'includes' . DS . 'functions.php';
     include_once ROOT . DS . 'includes' . DS . 'upload.php';
     $dg = new dg();
     $fonts = $dg->readFile($file);
     $fonts = json_decode($fonts, true);
     $font = $fonts['fonts']['fonts'];
     $data = array();
     $data['error'] = '';
     $data['id'] = $id;
     // get categories.
     $cate_font = ROOT . DS . 'data' . DS . 'font_categories.json';
     $cate = $dg->readFile($cate_font);
     $cates = json_decode($cate, true);
     $data['categories'] = $cates;
     // post data.
     if (isset($_POST['title']) && $_POST['title'] != '') {
         $title = $_POST['title'];
         //upload.
         $path = dirname(ROOT) . DS . 'data' . DS . 'fonts';
         if (!file_exists($path)) {
             mkdir($path, 0755);
         }
         $up = new upload();
         $up->permission = 755;
         $up->path = $path;
         $up->file_size = 2097152;
         // 2mb.
         $count = 0;
         $result = array();
         if (count($_FILES) == 3) {
             foreach ($_FILES as $key => $value) {
                 if (isset($_FILES[$key]['name']) && $_FILES[$key]['name'] != '') {
                     $checkname = array('~', '`', '!', '@', '#', '$', '%', '^', '&', '(', ')', '+', '=', '[', ']', '{', '}', ':', ' ', ',', '\'', ';');
                     $up->file_name = str_replace($checkname, '', $_FILES[$key]['name']);
                     if ($count == 0) {
                         $up->file_type[0] = 'woff';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             break;
                         }
                         $result[$count] = $val;
                     } elseif ($count == 1) {
                         $up->file_type[0] = 'ttf';
                         $up->file_type[1] = 'TTF';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             if (file_exists($result[0]['full_path'])) {
                                 unlink($result[0]['full_path']);
                             }
                             break;
                         }
                         $result[$count] = $val;
                     } else {
                         $up->file_type[0] = 'jpg';
                         $up->file_type[1] = 'png';
                         $up->file_type[2] = 'gif';
                         $up->file_type[3] = 'jpeg';
                         $val = $up->file($_FILES[$key]);
                         if ($val['error'] == 1) {
                             $data['error'] = $val['msg'];
                             if (file_exists($result[0]['full_path'])) {
                                 unlink($result[0]['full_path']);
                             }
                             if (file_exists($result[1]['full_path'])) {
                                 unlink($result[1]['full_path']);
                             }
                             break;
                         }
                         $result[$count] = $val;
                     }
                 }
                 $count++;
             }
         }
         //process.
         $subtitle = '';
         $cate_id = '';
         $catename = '';
         if (isset($_POST['subtitle'])) {
             $subtitle = $_POST['subtitle'];
         }
         if (isset($_POST['cate_id'])) {
             $cate_id = $_POST['cate_id'];
         }
         if ($catename == '' && isset($cates[$cate_id])) {
             $catename = $cates[$cate_id];
         }
         if ($id != '') {
             if (count($font) && $data['error'] == '') {
                 $font_out = array();
                 foreach ($font as $key => $val) {
                     if ($val['id'] == $id && $val['type'] == '') {
                         $filename = $val['filename'];
                         $path = $val['path'];
                         $thumb = $val['thumb'];
//.........这里部分代码省略.........
开发者ID:rootcave,项目名称:9livesprints-web,代码行数:101,代码来源:settings.php

示例3: replaceFile

 static function replaceFile()
 {
     global $page;
     $filename = get('filename');
     $file = $page->files()->find($filename);
     if (!$file) {
         return array('status' => 'error', 'msg' => l::get('files.replace.errors.notfound'));
     }
     $upload = upload::file('file', $page->root() . '/' . $filename);
     if (error($upload)) {
         return $upload;
     }
     self::killCache();
     return array('status' => 'success', 'msg' => l::get('files.replace.success'));
 }
开发者ID:nilshendriks,项目名称:kirbycms-panel,代码行数:15,代码来源:data.php

示例4: uploadFiles

 function uploadFiles($fileName, $uploadPath)
 {
     //require upload file
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers/upload.class.php';
     //define upload path
     $uploadPathMore = date('Y') . DS . date('m') . DS . date('d') . DS;
     $uploadPath .= $uploadPathMore;
     //echo $uploadPath; die;
     $files = JRequest::get('files');
     $post = JRequest::get('post');
     $files = $files['jform'];
     $name = array();
     $data = array();
     foreach ($post['jform']['images']['type'] as $key => $type) {
         if ($files['name']['images'][$key] != '' && !$files['error']['images'][$key]) {
             //set image name
             $imageName = $fileName . '-' . time() . '.' . end(explode('.', $files['name']['images'][$key]));
             //upload file
             $upload = upload::file($files, 'images', $uploadPath, $imageName, $key, false);
             //if upload OK
             if (is_array($upload) && $upload['result'] == 'OK') {
                 $data[] = array('image' => str_replace(DS, '/', $uploadPathMore) . $upload['file_name'], 'type' => $type);
             } else {
                 JError::raiseNotice('UPLOAD_ERROR', 'Upload Error');
             }
         }
     }
     //$data = serialize($data);
     return $data;
 }
开发者ID:salomalo,项目名称:nbs-01,代码行数:30,代码来源:apartment_man.php


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