<?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>

echo "不允许上传该类型的文件的更多相关文章

  1. input上传指定类型的文件

    1. 谷歌–上传文件夹 添加属性webkitdirectory <input type = "file" webkitdirectory> 2. 上传文件–限制类型 添 ...

  2. php 文件上传后缀名与文件类型对照表(几乎涵盖所有文件)

    网上有很多php文件上传的类,文件上传处理是php的一个特色(至少手册上是将此作为php特点来展示的,个人认为php在数组方面的优异功能更有特 色),学php的人都知道文件上传怎么做,但很多人在编程中 ...

  3. MVC下form表单一次上传多种类型的图片(每种类型的图片可以上传多张)

    form表单一次上传多种类型的图片(每种类型的图片可以上传多张) controller中的action方法 public ActionResult UploadImage( )        { in ...

  4. PHP文件上传错误类型及说明

    从 PHP 4.2.0 开始,PHP 将随文件信息数组一起返回一个对应的错误代码.该代码可以在文件上传时生成的文件数组中的 error 字段中被找到,也就是 $_FILES['userfile'][' ...

  5. PHP上传(单个)文件示例

    通过 PHP,可以把文件上传到服务器. 创建一个文件上传表单 允许用户从表单上传文件是非常有用的. 请看下面这个供上传文件的 HTML 表单: <html> <body> &l ...

  6. PHP实现单文件、多文件上传 封装 面向对象实现文件上传

    文件上传配置 客户端配置 1.表单页面 2.表单的发送方式为post 3.添加enctype = "multipart/form-data" <form action=&qu ...

  7. 上传漏洞科普[1]-文件上传表单是Web安全主要威胁

    为了让最终用户将文件上传到您的网站,就像是给危及您的服务器的恶意用户打开了另一扇门.即便如此,在今天的现代互联网的Web应用程序,它是一种 常见的要求,因为它有助于提高您的业务效率.在Facebook ...

  8. PHP核心编程--文件上传(包含多文件上传)

    一.单文件上传 图片上传界面: <!DOCTYPE html> <html lang="en"> <head> <meta charset ...

  9. Ajax实现文件上传的临时垃圾文件回收策略

    转载请注明原文出处:http://www.cnblogs.com/ygj0930/p/6126240.html 在我们web开发过程中,一个很重要的技术就是Ajax(异步传输).Ajax通过把数据从网 ...

随机推荐

  1. iOS NSURLConnection 和 dispatch_async 错误的使用方法,导致回调方法无法调用

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{ NSMutableURLRequest ...

  2. Java for LeetCode 029 Divide Two Integers

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  3. extjs在窗体中添加搜索框

    在extjs中添加搜索框,搜索框代码如下: this.searchField = new Ext.ux.form.SearchField({            store : this.store ...

  4. ubuntu使用root账户登录

    1.先设定一个root的密码 sudo passwd root 2.编辑lightdm.conf sudo gedit /etc/lightdm/lightdm.conf 最后一行添加 greeter ...

  5. ECSHOP去版权与标志

    前台部分: 1:去掉头部TITLE部分的ECSHOP演示站 Powered by ecshop 前者在后台商店设置 - 商店标题修改 后者打开includes/lib_main.php $page_t ...

  6. Ajax案例(使用ajax进行加法运算)

    此案例功能实现了一边看视频一边进行加法运算,而加法运算时页面不会刷新请求 ajax代码: <script type="text/javascript" src="j ...

  7. cocos2dx创建sprite的多种方法

    方法一 最常用,也是最简单的一种方法 CCSprite *bg=CCSprite::create(,,,)); bg->setAnchorPoint(ccp(,)); bg->setPos ...

  8. ctrl + z fg bg

    [root@bass ~]# jobs [1]+ Stopped vncviewer 192.168.1.17:5904 [root@bass ~]# #ctrl + z [root@bass ~]# ...

  9. ***linux下用cron定时执行任务的方法

    名称 : crontab  使用权限 : 所有使用者 使用方式 : crontab file [-u user]-用指定的文件替代目前的crontab. crontab-[-u user]-用标准输入 ...

  10. Java Hour 32 Weather ( 5 ) struts2 – Action class

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. Hour 32 Struts2 Action 1 将action 映射到 ac ...