• echo "不允许上传该类型的文件


    <?php教程

     // 上传设置
     $maxsize=10002400;            //最大允许上传的文件大小
     $alltype=array(".php",".php3");         //所有允许上传的文件类型
     $imgtype=array(".php",".php3");               //类型

     // 判断文件大小
     if($_FILES['file']['size']>$maxsize)  {
         echo "您上传的资料大于10000K";
         exit;
     }
     
     // 判断文件类型
     $type=strstr($_FILES['file']['name'],".");
     if(in_array($type,$alltype)){
         echo "不允许上传该类型的文件";
         exit;
     }
     include './uploaddir.php';
     $time=date("Ymd-His",time());
     $fn=$time.$type;
     $destination=$updir."/".$fn;
     if(@move_uploaded_file($_FILES['file']['tmp_name'], $destination)){
             @chmod($destination, 0777);
       $fileurl=$updir."/".$destination;
             $fileurl="".$destination;
               
     }else{
        echo "上传失败!";
        echo "<script>location.href=history.back()</script>";
     }
    // ----------------------------------------------------------------------------------------------//
    }
    if($back=="no"):
     echo "ok";
     exit;
    endif;
    ?>
    <html>
    <head>
    <title>上传文件</title>
    本文章为你提供一款简单的关于php文件上传功能的代码哦,如果你是php 初学者这款文件上传代码很容易理解哦,并且也很实例的。

    <script language="JavaScript">

    function isnull()
    {
             if(document.all.fileurl.value!="")insert();
    }
    function insert()
    {
            images='<a href="'+insertpic.fileurl.value+'">附带文件,请点击下载</a>';
            edit = window.opener.document.lfj_iframe.document.selection.createRange();
            edit.pasteHTML (images);
            window.close();
    }
    </script>
    <style>
    BODY {        FONT-SIZE: 12px; FONT-FAMILY: tahoma,宋体;}
    TABLE {        empty-cells: show;}
    TD {2881064151        FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: tahoma,宋体;margin: 5}
    </style>
    </head>
    <body leftMargin=12 topMargin=12 marginwidth=2 marginheight=2 bgcolor='#D6D3CE' style="border:0px" onload=isnull()>
    <form action=<?=$PHP_SELF?> name=insertpic enctype=multipart/form-data method=post>
    <table>
    <tr>
            <td></td>
            <td width=60>上传文件</td>
            <td><input class="mmcinb" type="file" name="file" size="14">
            <input class="mmcinb" type="submit" value="上传"></td>
    </tr>
    <tr>
            <td></td>
            <td>文件URL</td>
            <td><input class="mmcinb" type="text" name="fileurl" value="<?=$fileurl?>" size="26">
            <button onclick=insert()>插入</button></td>
    </tr>
    <tr>
            <td></td>
            
          <td colspan=2 align=left><font color=red>可以直接输入文件的URL,点击插入即可(不能有中文)<br>
            </font></td>
    </tr>
    </table>
    </form>
    <script language="JavaScript">
    <!--
            //picurl.focus();
    //-->
    </script>
    </body>
    </html>

  • 相关阅读:
    shell编程基础干货
    HIVE的高级操作
    Linux service,挂载,定时任务等常用服务
    Linux(二)高级文本处理
    Linux基本使用命令
    07-MySQL 架构介绍
    06-Re: 视图&过程&触发器
    05-安装 MySQL5.7
    [04] 继承&聚合&war
    [03] 仓库&生命周期&插件目标
  • 原文地址:https://www.cnblogs.com/cbryge/p/6108676.html
Copyright © 2020-2023  润新知