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


PHP FileUpload::getNewFileName方法代码示例

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


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

示例1: unlink

        $filename = $up->getNewFileName();
        unlink("../../images/environment/" . $_POST[env_pic]);
    } else {
        $filename = $_POST[env_pic];
    }
    $db->query("update cp set cp_info_type_zh_cn='{$_POST['zh_cn']}',cp_info_type_en='{$_POST['en']}',cp_info_value_zh_cn='{$_POST['content']}'," . "cp_info_value_en='{$_POST['content2']}', path='{$filename}' where id='" . $_POST[envid] . "'");
    echo "<script>alert('设备环境信息修改成功!');location.href='../envlist.php';</script>";
} else {
    if (isset($_POST[task]) && "addEnv" == $_POST[task]) {
        //文件保存目录URL
        $save_path = '../../images/environment';
        //定义允许上传的文件扩展名
        $ext_arr = array('gif', 'jpg', 'png');
        require "../action/FileUpload.class.php";
        $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100000));
        //100k
        if ($up->uploadFile('env_pic')) {
            $filename = $up->getNewFileName();
            $db->query("insert into cp(cp_info_type_zh_cn,cp_info_type_en,cp_info_value_zh_cn," . "cp_info_value_en,remark,path,create_date) values('{$_POST['zh_cn']}','{$_POST['en']}','{$_POST['content']}'," . "'{$_POST['content2']}','DeviceContext','{$filename}',now())");
            echo "<script>alert('设备环境信息添加成功!');location.href='../envlist.php';</script>";
        } else {
            echo "<script>alert('设备环境信息添加失败,请重试!');location.href='../envlist.php';</script>";
        }
    } else {
        if (isset($_GET[task]) && "deleteEnv" == $_GET[task]) {
            $db->query("delete from cp where id='{$_GET['envid']}'");
            unlink("../../images/environment/" . $_GET[path]);
            echo "<script>alert('设备环境信息删除成功!');location.href='../envlist.php';</script>";
        }
    }
}
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:env.action.php

示例2: array

         echo "<script>if(confirm('更新成功,是否继续更新?')){location.href='../editnav.php?task=toUpdateNav&navid={$_POST['navid']}';}else{location.href='../nav.php';}</script>";
     }
     //$db->query("update menu set menu_name_zh_cn='$_POST[name_cn]',menu_name_en='$_POST[name_en]',pid='$_POST[type]',`show`='$_POST[show]',remark='$_POST[remark]',url='$_POST[url]' where id='$_POST[navid]'");
     echo "<script>if(confirm('更新成功,是否继续更新?')){location.href='../editnav.php?task=toUpdateNav&navid={$_POST['navid']}';}else{location.href='../nav.php';}</script>";
 } else {
     if (isset($_POST[task]) && "addNav" == $_POST[task]) {
         if ($_POST[pid] != -1) {
             //文件保存目录URL
             $save_path = '../../images/pic/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('gif', 'jpg', 'png');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 100));
             if ($up->uploadFile('picture')) {
                 $filename = "images/pic/" . $up->getNewFileName();
                 $type = '';
                 $str = '';
                 $url = '';
                 if ("18" == $_POST[pid]) {
                     //产品
                     $type = $_POST[type];
                     $str = 'prodinfo.php?prodid=';
                 } else {
                     if ('1' == $_POST[pid]) {
                         //解决方案
                         $str = 'solutioninfo.php?solid=';
                     } else {
                         if ('8' == $_POST[pid]) {
                             //it服务
                             $str = 'itserviceinfo.php?itsid=';
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:nav.action.php

示例3: replace

         $filename4 = "images/case/" . $up->getNewFileName();
     }
     $db->query("insert into `case`(case_name,case_type,case_url,case_cust,case_desc,create_date,case_pic,case_pic_a,case_pic_b,case_pic_c) " . "values('{$_POST['name']}','{$_POST['type']}','{$_POST['url']}','{$_POST['cust']}','" . replace($_POST[content]) . "',now(),'{$filename1}','{$filename2}','{$filename3}','{$filename4}')");
     echo "<script>if(confirm('增加案例成功,是否继续新增?')){location.href='../addcase.php';}else{ location.href='../case.php';}</script>";
 } else {
     if (isset($_POST[task]) && "updateCase" == $_POST[task]) {
         //文件保存目录URL
         $save_path = '../../images/case/';
         //定义允许上传的文件扩展名
         $ext_arr = array('gif', 'jpg', 'JGG', 'GIF', 'PNG', 'png');
         require "../action/FileUpload.class.php";
         $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
         $sql = "update `case` set case_name='{$_POST['name']}',case_type='{$_POST['type']}',case_url='{$_POST['url']}'," . "case_cust='{$_POST['cust']}',";
         if ($up->uploadFile('case1')) {
             //上传后产品图片名称 放到数据库
             $filename1 = "images/case/" . $up->getNewFileName();
             if (file_exists("../../" . $_POST[path1])) {
                 unlink("../../" . $_POST[path1]);
             }
             $sql = $sql . " case_pic='{$filename1}',";
         }
         if ($up->uploadFile('case2')) {
             //上传后产品图片名称 放到数据库
             $filename2 = "images/case/" . $up->getNewFileName();
             if (file_exists("../../" . $_POST[path2])) {
                 unlink("../../" . $_POST[path2]);
             }
             $sql = $sql . " case_pic_a='{$filename2}',";
         }
         if ($up->uploadFile('case3')) {
             //上传后产品图片名称 放到数据库
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:case.action.php

示例4: FileUpload

<?php

require "FileUpload.class.php";
$up = new FileUpload(array('isRandName' => true, 'allowType' => array('txt', 'doc', 'php', 'gif'), 'FilePath' => './uploads/', 'MAXSIZE' => 200000));
echo '<pre>';
if ($up->uploadFile('spic')) {
    print_r($up->getNewFileName());
} else {
    print_r($up->getErrorMsg());
}
echo '</pre>';
开发者ID:hellowords,项目名称:phptest,代码行数:11,代码来源:upload.php

示例5: array

                            $id = $db->insert_id();
                            echo "<script>alert('视讯信息添加成功,请上传视讯文件?');location.href='../videoadd.php?task=uploadVideoFile&id={$id}';</script>";
                        } else {
                            print_r($up->getErrorMsg());
                            echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php;</script>";
                        }
                    } else {
                        if (isset($_POST[task]) && "addVideoFile" == $_POST[task]) {
                            //文件保存目录路径
                            $save_path = '../../../video/file/';
                            //定义允许上传的文件扩展名
                            $ext_arr_file = array('swf', 'avi', 'asf', 'mid', 'wmv', 'wma', 'ra');
                            require "FileUpload.class.php";
                            $upFile = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr_file, 'FilePath' => $save_path, 'MAXSIZE' => 200485760));
                            if ($upFile->uploadFile('upfile')) {
                                //print_r($up->getNewFileName());
                                $fname = $upFile->getNewFileName();
                                $sql = "update video set video_path='../video/file/{$fname}' where id = {$_POST['id']}";
                                $db->query($sql);
                                echo "<script>if(confirm('视讯添加完成,是否继续添加?')){location.href='../videoadd.php';}else{location.href='../videolist.php';}</script>";
                            } else {
                                print_r($upFile->getErrorMsg());
                                echo "<script>alert('视讯添加失败,是否重试?');location.href='../videoadd.php';</script>";
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:action.php

示例6: explode

             $picurlarr = explode('/', $arr['flash']['url']);
             if ($picurlarr[count($picurlarr) - 2] != 'guanggao' && $picurlarr[count($picurlarr) - 3] != 'uploadfiles') {
                 //手填路径
                 $ordername = '';
             } else {
                 //选择图片提交
                 $picstr = $picurlarr[count($picurlarr) - 1];
                 $picarr = explode('.', $picstr);
                 array_pop($picarr);
                 $ordername = implode('.', $picarr);
             }
         }
     }
     $up = new FileUpload(array('isRandName' => true, 'allowType' => array('swf'), 'FilePath' => $filepath, 'MAXSIZE' => 20 * 1024 * 1024, 'ordername' => $ordername));
     if ($up->uploadFile('flashpic')) {
         $_POST['adv']['flash']['url'] = '/uploadfiles/guanggao/' . $up->getNewFileName();
     } else {
         redirect($up->getErrorMsg(), '-1');
     }
 }
 //zhaoyanmin end
 $code = addslashes(serialize($_POST['adv']));
 !$varname && alert("广告标识符不能为空");
 if ($id) {
     $DreamCMS->db->query("UPDATE `#DC@__advertise` SET `varname` = '{$varname}',`title` = '{$title}',`style`='{$style}',`starttime` = '{$starttime}',`endtime` = '{$endtime}',`code` = '{$code}',`status` = '{$state}' WHERE `id` ='{$id}'");
 } else {
     $DreamCMS->db->query("INSERT INTO `#DC@__advertise`(`varname` , `title` ,`style`, `starttime` , `endtime` , `code` , `status` ) VALUES ('{$varname}','{$title}','{$style}','{$starttime}', '{$endtime}', '{$code}', '{$state}')");
     $id = $DreamCMS->db->insert_id;
 }
 $jsfile = "YWR2ZXJ0aXNl/{$style}-id-{$id}.js";
 $html = getadvhtml($style, stripslashes($code));
开发者ID:20000Hz,项目名称:bak-letvs,代码行数:31,代码来源:advertise.inc.php

示例7: cp

        $db->query("insert into cp(cp_info_type_en,cp_info_type_zh_cn,cp_info_value_en,cp_info_value_zh_cn,remark,seq,path,create_date) values('{$_POST['ryzz_name_en']}','{$_POST['ryzz_name_zh_cn']}','" . addslashes($_POST[content2]) . "','" . addslashes($_POST[content]) . "','Honour',null,'{$filename}',now())");
        echo "<script>alert('增加荣誉资质成功');location.href='../ryzz.php';</script>";
    } else {
        echo "<script>alert('增加荣誉资质失败');location.href='../addryzz.php';</script>";
    }
} else {
    if (isset($_GET[task]) && "deleteryzz" == $_GET[task]) {
        $db->query("delete from cp where id = '{$_GET['ryzzid']}'");
        echo "<script>alert('荣誉资质删除成功?');location.href='../ryzz.php';</script>";
    } else {
        if (isset($_POST[task]) && "updateryzz" == $_POST[task]) {
            //文件保存目录URL
            $save_path = '../../images/cert/';
            //定义允许上传的文件扩展名
            $ext_arr = array('gif', 'jpg', 'png');
            require "../action/FileUpload.class.php";
            $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 500));
            if ($up->uploadFile('ryzz_pic')) {
                $query = $db->query("select path from cp where id='{$_POST['prod_id']}'");
                $info = $db->fetch_array($query);
                $filename = "images/cert/" . $up->getNewFileName();
                $db->query("update cp set cp_info_type_zh_cn='{$_POST['ryzz_name_zh_cn']}',cp_info_type_en='{$_POST['ryzz_name_en']}',cp_info_value_zh_cn='" . addslashes($_POST[content]) . "',cp_info_value_en='" . addslashes($_POST[content2]) . "',path='{$filename}' where id='{$_POST['ryzz_id']}'");
                //unlink("../../".$info[path]);
                echo "<script>alert('修改成功!');location.href='../ryzz.php';</script>";
            } else {
                $db->query("update cp set cp_info_type_zh_cn='{$_POST['ryzz_name_zh_cn']}',cp_info_type_en='{$_POST['ryzz_name_en']}',cp_info_value_zh_cn='" . addslashes($_POST[content]) . "',cp_info_value_en='" . addslashes($_POST[content2]) . "' where id='{$_POST['ryzz_id']}'");
                echo "<script>alert('图片修改失败或者图片没有修改,广告其他信息修改成功!');location.href='../ryzz.php';</script>";
            }
        }
    }
}
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:ryzz.action.php

示例8: replace

                 } else {
                     $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "',type_id='{$_POST['type']}' where id='{$_POST['newsid']}'");
                     echo "<script>alert('文章内容更新成功,文件更新失败,请检查上传文件是否符合要求!');location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';</script>";
                 }
             }
         } else {
             //文件保存目录URL
             $save_path = '../../images/upload/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('jpg', 'gif', 'png');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 100 * 1024));
             //100k
             if ($up->uploadFile('filepath')) {
                 $filename = "images/upload/" . $up->getNewFileName();
                 $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "'," . "type_id='{$_POST['type']}',isshow='1',path='{$filename}' where id='{$_POST['newsid']}'");
                 if ($_POST[srcisshow] == '1') {
                     if (file_exists("../../" . $_POST[path])) {
                         unlink("../../" . $info[path]);
                     }
                 }
                 echo "<script>if(confirm('文章内容、图片更新成功,是否继续更新?')){location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';}else{location.href='../news.php';}</script>";
             } else {
                 $db->query("update news set title='{$_POST['title']}',click='{$_POST['click']}',content='" . replace($_POST[content]) . "'," . "type_id='{$_POST['type']}' where id='{$_POST['newsid']}'");
                 echo "<script>alert('文章内容更新成功,图片更新失败,请检查图片格式是否符合要求!');location.href='../post/news.action.php?task=toUpdateNews&newsid={$_POST['newsid']}';</script>";
             }
         }
     }
 } else {
     if (isset($_POST[task]) && "AddType" == $_POST[task]) {
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:news.action.php

示例9: unlink

             if ($_POST[old_content_type] == 1 && !empty($_POST[path])) {
                 unlink('../../' . $_POST[path]);
             }
             $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}',path=''," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}',content='" . replace($_POST[content]) . "' where id='{$_POST['classid']}' ");
             echo "<script>if(confirm('课程修改成功,是否继续修改?')){location.href='../updateclass.php?task=updateClass&classid={$_POST['classid']}';}else{location.href='../classlist.php';}</script>";
         } else {
             //文件保存目录URL
             $save_path = '../../file/';
             //201109281154581.jpg
             //定义允许上传的文件扩展名
             $ext_arr = array('doc', 'docx', 'xls', 'xlsx', 'txt');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 1024 * 10));
             //10M
             if ($up->uploadFile('path')) {
                 $filename = "file/" . $up->getNewFileName();
                 $srcfilename = $up->getSrcFileName();
                 if ($_POST[old_content_type] == 1 && !empty($_POST[path])) {
                     unlink('../../' . $_POST[path]);
                 }
                 $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}'," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}',path='{$filename}',content='{$srcfilename}'  where id='{$_POST['classid']}' ");
                 echo "<script>if(confirm('课程修改成功,是否继续修改?')){location.href='../updateclass.php?task=updateClass&classid={$_POST['classid']}';}else{location.href='../classlist.php';}</script>";
             } else {
                 $db->query("update boya_course set type_id='{$_POST['type_id']}',class_name='{$_POST['classtype']}'," . "open_time='{$_POST['opentime']}',course_name='{$_POST['classname']}',class_hour='{$_POST['hour']}'," . "fee='{$_POST['fee']}',content_type='{$_POST['content_type']}' where id='{$_POST['classid']}' ");
                 echo "<script>if(confirm('文件修改失败或没有修改,基础信息修改成功,是否继续修改?')){location.href='../addclass.php';}else{location.href='../classlist.php';}</script>";
             }
         }
     }
 } else {
     if (isset($_GET[task]) && "deleteClass" == $_GET[task]) {
         if (!empty($_GET[path])) {
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:class.action.php

示例10: array

     //修改联系方式 ../images/tou.gif
 } else {
     if (isset($_POST[task]) && "modifyLinkInfo" == $_POST[task]) {
         $db->query("update comm_code set comm_code='{$_POST['content']}' where comm_type='Logo' and remark='LinkInfo'");
         echo "<script>alert('Logo联系方式修改成功!');location.href='../logo.php';</script>";
         //修改modifyBanner
     } else {
         if (isset($_POST[task]) && "modifyBanner" == $_POST[task]) {
             //文件保存目录URL
             $save_path = '../../images/banner/';
             //定义允许上传的文件扩展名
             $ext_arr = array('gif', 'jpg', 'png');
             require "../action/FileUpload.class.php";
             $up = new FileUpload(array('isRandName' => true, 'allowType' => $ext_arr, 'FilePath' => $save_path, 'MAXSIZE' => 1024 * 150));
             if ($up->uploadFile('filePath')) {
                 $filename = "images/banner/" . $up->getNewFileName();
                 $db->query("update comm_code set comm_code='{$filename}',flag='{$_POST['flag']}',comm_value='{$_POST['comm_value']}' where comm_type='Index_AD' and id='{$_POST['adid']}'");
                 if (file_exists("../../" . $_POST[path])) {
                     unlink("../../" . $_POST[path]);
                 }
                 echo "<script>alert('Banner信息、图片修改成功!');location.href='../indexad.php';</script>";
             } else {
                 $db->query("update comm_code set flag='{$_POST['flag']}',comm_value='{$_POST['comm_value']}' where comm_type='Index_AD' and id='{$_POST['adid']}'");
                 echo "<script>alert('Banner信息修改成功!');location.href='../indexad.php';</script>";
             }
             $db->query("update comm_code set type_content='" . htmlentities($_POST[content]) . "' where lang='zh_cn' and type_name='ContactUs' ");
             echo "<script>alert('联系我们[中文]信息修改成功?');location.href='../contactus.php';</script>";
             //更新在线客服信息
         } else {
             if (isset($_POST[task]) && "updateImConfig" == $_POST[task]) {
                 $db->query("update comm_code set comm_code='{$_POST['comm_code']}',comm_value='{$_POST['comm_value']}' where comm_type='OnlineService' and id='{$_POST['onlineid']}'");
开发者ID:soross,项目名称:myteashop,代码行数:31,代码来源:config.action.php

示例11: array

<?php

require_once 'logincheck.php';
require_once '../library/uploadfile.php';
require_once '../library/excel/reader.php';
$option = array('filepath' => '../upload', 'allowtype' => array('xls'), "maxsize" => "10000000", "israndname" => true);
$file = new FileUpload($option);
if (!$file->uploadFile("uploadfile")) {
    //获取要上传的文件,上传
    $message = $file->getErrorMsg();
} else {
    //插入到数据库中
    $xl = new Spreadsheet_Excel_Reader();
    $xl->setOutputEncoding('CP936');
    $xl->read($option["filepath"] . '/' . iconv("utf-8", "GBK", $file->getNewFileName()));
    $succeed = 0;
    $lost = 0;
    for ($i = 2; $i <= $xl->sheets[0]['numRows']; $i++) {
        $data['STU_NUM'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][1]));
        $data['STU_NAME'] = str_replace(' ', '', iconv("GBK", "utf-8", $xl->sheets[0]['cells'][$i][2]));
        $data['STU_DEP'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][3]));
        $data['STU_PSW'] = $data['STU_NUM'];
        $data['EXAM_YEAR'] = str_replace(' ', '', iconv("gb2312", "utf-8", $xl->sheets[0]['cells'][$i][4]));
        if ($db->insert("stuinfo", $data)) {
            $succeed++;
        } else {
            $lost++;
        }
    }
    $message = "成功导入" . $succeed . "条记录,失败" . $lost . "条";
}
开发者ID:dalinhuang,项目名称:dangke,代码行数:31,代码来源:upandinsert.php


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