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


PHP file::uploadfile方法代码示例

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


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

示例1: doupload

 function doupload()
 {
     @header('Content-type: text/html; charset=' . WIKI_CHARSET);
     $did = $this->post['did'] ? $this->post['did'] : 0;
     if (!$this->setting['attachment_open']) {
         exit;
     }
     $okfile = '';
     $this->setting['coin_download'] = isset($this->setting['coin_download']) ? $this->setting['coin_download'] : 10;
     $count = count($_FILES['attachment']['name']);
     for ($i = 0; $i < $count; $i++) {
         if (!(bool) $_FILES['attachment']['name'][$i]) {
             continue;
         }
         $size = $_FILES['attachment']['size'][$i] / 1024;
         $name = $_FILES['attachment']['name'][$i];
         $attachment_type = $_ENV['attachment']->get_attachment_type();
         $filetype = strtolower(substr($name, strrpos($name, ".") + 1));
         if ($attachment_type[0] != '*' && !in_array($filetype, $attachment_type)) {
             echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachTypeError'] . '");</script>';
             continue;
         }
         if ($size > $this->setting['attachment_size'] || empty($size)) {
             echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachSizeError2'] . '");</script>';
             continue;
         }
         $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
         file::createaccessfile('data/attachment/' . date('y-m') . '/');
         $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->setting['attachment_size'], 0);
         if ($result) {
             $okfile .= $name . '|';
             $coindown = $this->post['coin_download'][$i];
             if (empty($coindown) || !is_numeric($coindown)) {
                 $coindown = 0;
             } else {
                 if (0 > $coindown) {
                     $coindown = 0;
                 } else {
                     if ($this->setting['coin_download'] < $coindown) {
                         $coindown = $this->setting['coin_download'];
                     }
                 }
             }
             $_ENV['attachment']->add_attachment($this->user['uid'], $did, $name, $destfile, $this->post['attachmentdesc'][$i], $filetype, 0, $coindown);
         }
     }
     echo '<script>';
     if ($okfile) {
         echo 'parent.Attachment.addok("' . $okfile . '");';
     }
     echo '</script>';
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:52,代码来源:attachment.php

示例2: upload_attachment

 function upload_attachment($did)
 {
     if (!$this->base->setting['attachment_open']) {
         return false;
     }
     $count = count($_FILES['attachment']['name']);
     for ($i = 0; $i < $count; $i++) {
         if (!(bool) $_FILES['attachment']['name'][$i]) {
             continue;
         }
         $attachment_type = $this->get_attachment_type();
         $filetype = strtolower(substr($_FILES['attachment']['name'][$i], strrpos($_FILES['attachment']['name'][$i], ".") + 1));
         if (!in_array($filetype, $attachment_type)) {
             $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachTypeError'] . "<br />";
             continue;
         }
         if ($this->base->setting['attachment_size'] < $_FILES['attachment']['size'][$i] / 1024) {
             $message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachSizeError'] . "<br />";
             continue;
         }
         $destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
         file::createaccessfile('data/attachment/' . date('y-m') . '/');
         $result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->base->setting['attachment_size'], 0);
         if ($result) {
             $_ENV['attachment']->add_attachment($this->base->user['uid'], $did, $_FILES['attachment']['name'][$i], $destfile, $this->base->post['attachmentdesc'][$i], $filetype, 0);
         }
     }
     return $message;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:29,代码来源:attachment.class.php

示例3: doedit

 function doedit()
 {
     if (!isset($this->post['submit'])) {
         $id = $this->get[2];
         $gift = $_ENV['gift']->get($id);
         $this->view->assign("gift", $gift);
         $this->view->display('admin_editgift');
     } else {
         $id = trim($this->post['id']);
         $gift = $_ENV['gift']->get($id);
         $title = htmlspecialchars(trim($this->post['title']));
         $credit = trim($this->post['credit']);
         $description = htmlspecialchars(trim($this->post['description']));
         $imgname = $_FILES['giftfile']['name'];
         /*
         if($gift['image']){
         	$destfile=str_replace('_s.', '.', $gift['image']);
         }else{
         	$extname=file::extname($imgname);
         	$destfile = 'uploads/gift/'.util::random(8).'.'.$extname;
         }
         */
         if ('' != $imgname) {
             $extname = file::extname($imgname);
             $destfile = 'uploads/gift/' . util::random(8) . '.' . $extname;
             file::uploadfile($_FILES['giftfile'], $destfile);
             util::image_compress($destfile, '', 500, 500, '');
             $iamge = util::image_compress($destfile, '', 106, 106, '_s');
             $destfile = $iamge['tempurl'];
         }
         $_ENV['gift']->edit($id, $title, $credit, $description, $destfile);
         $this->message($this->view->lang['usermanageOptSuccess'], 'index.php?admin_gift-search');
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:34,代码来源:admin_gift.php

示例4: fileip

 function fileip($alluploadips, $regular, $attachment_size)
 {
     $filetype = strtolower(substr($_FILES['file_path']['name'], strrpos($_FILES['file_path']['name'], ".") + 1));
     $destfile = 'data/tmp/' . time() . '.' . $filetype;
     $result = file::uploadfile($_FILES['file_path']['tmp_name'], $destfile, $attachment_size, 0);
     if ($result) {
         if (file_exists($destfile)) {
             $data = file::readfromfile($destfile);
         }
         $alluploadips = $this->textip($alluploadips, $regular, $data);
         @unlink($destfile);
     }
     return $alluploadips;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:14,代码来源:banned.class.php

示例5: filewords

 function filewords($alluploadwords, $attachment_size)
 {
     $filetype = strtolower(substr($_FILES['file_path']['name'], strrpos($_FILES['file_path']['name'], ".") + 1));
     $destfile = 'data/tmp/' . time() . '.' . $filetype;
     $result = file::uploadfile($_FILES['file_path']['tmp_name'], $destfile, $attachment_size, 0);
     if ($result) {
         if (file_exists($destfile)) {
             if (WIKI_CHARSET == 'UTF-8') {
                 $data = string::hiconv(file::readfromfile($destfile), 'utf-8');
             } else {
                 $data = string::hiconv(file::readfromfile($destfile), 'gbk');
             }
         }
         $filewords = array_filter(explode(',', str_replace(',', ',', addslashes($data))), array($this, "trimwords"));
         $alluploadwords = array_merge($alluploadwords, $filewords);
         @unlink($destfile);
     }
     return $alluploadwords;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:19,代码来源:word.class.php

示例6: doshare

 function doshare()
 {
     $pluginid = $this->get[2];
     if (!isset($this->post['submit'])) {
         $plugin = $this->db->fetch_by_field('plugin', 'pluginid', $pluginid);
         if (file_exists(HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/share.lock')) {
             $this->message($this->view->lang['pluginRepeatShareFail'], 'index.php?admin_plugin');
         }
         $plugin['authorurl'] = empty($plugin['authorurl']) ? 'http://' : $plugin['authorurl'];
         $plugin['weburl'] = empty($plugin['weburl']) ? 'http://' : $plugin['weburl'];
         $this->view->assign('plugin', $plugin);
         $this->view->display('admin_pluginshare');
     } else {
         $plugin['author'] = $this->post['author'];
         $plugin['authorurl'] = $this->post['authorurl'];
         $plugin['name'] = $this->post['name'];
         $plugin['tag'] = $this->post['tag'];
         $plugin['weburl'] = $this->post['weburl'];
         $plugin['version'] = $this->post['version'];
         $plugin['hdversion'] = HDWIKI_VERSION;
         $plugin['copyright'] = $this->post['copyright'];
         $plugin['description'] = $this->post['description'];
         $plugin['identifier'] = $this->post['identifier'];
         file::uploadfile($_FILES['pluginimg'], HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/screenshot.jpg');
         $share = $_ENV['plugin']->share_plugin($plugin);
         if ($share) {
             @touch(HDWIKI_ROOT . '/plugins/' . $plugin['identifier'] . '/share.lock');
             $this->message($this->view->lang['pluginShareSuccess'], 'index.php?admin_plugin');
         } else {
             $this->message($this->view->lang['pluginShareFail'], 'index.php?admin_plugin');
         }
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:33,代码来源:admin_plugin.php

示例7: dologo

 function dologo()
 {
     if (!isset($this->post['logsubmit'])) {
         $this->view->assign('logowidth', $this->setting['logowidth']);
         $this->view->display("admin_uploadlogo");
     } else {
         $settings['logowidth'] = $this->post['logowidth'] ? $this->post['logowidth'] : '220px';
         $setting = $_ENV['setting']->update_setting($settings);
         $this->cache->removecache('setting');
         if ($_FILES['logo']['name']) {
             $imgname = $_FILES['logo']['name'];
             $filetype = array('image/jpeg', 'image/gif', 'image/x-png', 'image/png', 'image/pjpeg');
             if (in_array($_FILES['logo']['type'], $filetype)) {
                 $destfile = 'style/default/logo.gif';
                 $arrupload = file::uploadfile($_FILES['logo'], $destfile, 1024);
                 if (isset($arrupload) && $arrupload['result'] == true) {
                     $this->message($arrupload['msg'], 'index.php?admin_setting-logo');
                 } else {
                     $this->message($this->view->lang['uploadFail'], 'BACK');
                 }
             } else {
                 $this->message($this->view->lang['uploadFormatWrong'], 'BACK');
             }
         }
         $this->message('宽度修改成功!', 'index.php?admin_setting-logo');
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:27,代码来源:admin_setting.php

示例8: doeditxml

 function doeditxml()
 {
     if (!isset($this->post['stylesave']) && !isset($this->post['styleshare'])) {
         $xmlcon = $_ENV['theme']->read_xml($this->get[2]);
         $this->view->assign('stylename', $this->get[2]);
         $this->view->assign('style', $xmlcon);
         $this->view->assign('share', $this->get[3]);
         $this->view->display('admin_themexml_edit');
     } else {
         if ($_FILES['styleimg']['name'] != '') {
             $image = $_FILES['styleimg'];
             $extname = file::extname($image['name']);
             if ($extname == 'jpg') {
                 $destfile = 'style/' . $this->get[2] . '/screenshot.' . $extname;
                 $result = file::uploadfile($image, $destfile);
                 if ($result['result']) {
                     util::image_compress($destfile, NULL, 158, 118);
                 } else {
                     $this->message($result['msg'], 'BACK');
                 }
             } else {
                 $this->message($this->view->lang['uploadFormatWrong'], 'BACK');
             }
         }
         //insert into db
         $style = $this->post['style'];
         $style['hdversion'] = HDWIKI_VERSION;
         $style['path'] = trim($this->get[2]);
         $style['charset'] = $_ENV['theme']->style_charset($style[path]);
         $stylecon = $_ENV['theme']->add_check_style($style['path']);
         if ($stylecon == null) {
             $_ENV['theme']->add_style($style);
         } else {
             $_ENV['theme']->update_style($style);
         }
         //得到需要插入的blocks的sql。
         $style['sql'] = '';
         $blocks = $_ENV['theme']->get_blocks_by_theme($this->get[2]);
         if ($blocks) {
             $insertsql = "INSERT INTO wiki_block (theme,file,area,areaorder,block,fun,tpl,params) VALUES ";
             foreach ($blocks as $val) {
                 $insertsql .= "( '{$val['theme']}','{$val['file']}','{$val['area']}','{$val['areaorder']}','{$val['block']}','{$val['fun']}','{$val['tpl']}','{$val['params']}' ),";
             }
             $style['sql'] = substr($insertsql, 0, -1);
         }
         //write to xml
         $_ENV['theme']->write_xml($style);
         if (isset($this->post['stylesubmit'])) {
             $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme');
         } else {
             if (isset($this->post['stylesave'])) {
                 $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme-editxml-' . $style[path] . '-share');
             } else {
                 if (isset($this->post['styleshare'])) {
                     //check
                     $filename = 'style/' . $style['path'] . '/share.lock';
                     if (is_file($filename)) {
                         $this->message($this->view->lang['style_share_lock'] . $filename, 'BACK');
                     } else {
                         file::writetofile($filename, $a = '');
                     }
                     //zip
                     require HDWIKI_ROOT . "/lib/zip.class.php";
                     $zip = new Zip();
                     $filedir = array('style/' . $style['path'], 'view/' . $style['path'], 'block/' . $style['path']);
                     $zipdir = array('hdwiki/style/' . $style['path'], 'hdwiki/view/' . $style['path'], 'hdwiki/block/' . $style['path']);
                     file::forcemkdir(HDWIKI_ROOT . '/data/tmp/');
                     $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
                     @$zip->zip_dir($filedir, $tmpname, $zipdir);
                     //share
                     if (is_file($tmpname)) {
                         $zip_content = file::readfromfile($tmpname);
                         $upload_url = $this->setting['app_url'] . "/hdapp.php?action=upload&type=template";
                         $data = 'data=' . base64_encode($zip_content);
                         unlink($tmpname);
                         if ('1' == @util::hfopen($upload_url, 0, $data)) {
                             $this->message($this->view->lang['styleShareSuccess'], 'index.php?admin_theme');
                         } else {
                             $this->message($this->view->lang['styleShareFaile'], 'index.php?admin_theme');
                         }
                     } else {
                         $this->message($this->view->lang['styleFileZipFail'], 'index.php?admin_theme');
                     }
                 }
             }
         }
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:88,代码来源:admin_theme.php

示例9: upload_img

 function upload_img($uploadimg, $filename)
 {
     $counts = count($uploadimg);
     if ($counts != 0) {
         for ($i = 0; $i < $counts; $i++) {
             $imgname = $uploadimg[$i]['name'];
             $extname = file::extname($imgname);
             $destfile = HDWIKI_ROOT . '/style/' . $filename . '/' . $uploadimg[$i]['rename'] . "." . $extname;
             $result = file::uploadfile($uploadimg[$i], $destfile);
             if ($result['result'] && $uploadimg[$i]['rename'] == 'screenshot') {
                 util::image_compress($destfile, NULL, 158, 118);
             }
             $success++;
         }
     }
     return $success;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:17,代码来源:theme.class.php


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