<?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. mysql 源码下载列表

    2013年11月16日 14:57:04 http://download.softagency.net/MySQL/Downloads/MySQL-5.5/ http://code.google.co ...

  2. mysqldump备份

    备份工具1.mysqldump(数据量很大时不推荐使用)   myisam 锁表   innodb 行锁 mysqldump --help | less   #查看mysql所有的语法 mysqldu ...

  3. HDU1712周期

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  4. MFC 相关文件夹、文件操作

    //关于文件(夹)操作,可以参考下SHFileOperation这个外壳函数,貌似可以显示进度条.以下没有使用SHFileOperation//删除一个文件夹下的所有内容void myDeleteDi ...

  5. php请求URL中的参数有空格

    url=http://www.123.com/abc.php?name=ku xiong ku xiong之间有一个空格,需要替换成%20或者+ url=http://www.123.com/abc. ...

  6. [Linux] Linux进程PID散列表

    linux系统中每个进程由一个进程id标识,在内核中对应一个task_struct结构的进程描述符,系统中所有进程的task_struct通过链表链接在一起,在内核中,经常需要通过进程id来获取进程描 ...

  7. [SVN(ubuntu)] ubuntu使用svn

    转载自:http://lee2013.iteye.com/blog/1058047 SVN作为日常开发中不可缺少的工具,Ubuntu下的SVN安装十分简单,sudo apt-get install s ...

  8. javascript类的类比详解-大白话版

    转载请注明出处:水车 如果有误,还望指出,谢谢 -----------------正文分割线---------------------- 类:类太抽象,要想弄明白就该用现实的东西来类比 在我看来类就是 ...

  9. linux 远程 windows 命令:rdesktop vs windows mstsc

    [root@bass tmp]# which rdesktop /usr/bin/rdesktop [root@bass tmp]# rpm -qf /usr/bin/rdesktop rdeskto ...

  10. JAVA基础学习之String、StringBuffer、StringBuilder、基本数据类型的使用、整形进制转换、集合Collection、Vector、ArrayList、LinkedList、HashSet、TreeSet等(3)

    主函数类MainDemo.java package com.itcast.test20140109; import java.util.ArrayList; import java.util.Coll ...