zoukankan      html  css  js  c++  java
  • PHP文件上传学习

    PHP文件上传学习

    <?php
    // 判断是否有文件上传
    if (!isset($_FILES['upfile'])) {
        die('No uploaded file.');
    }
    
    // 判断是否有错误
    if ($_FILES['upfile']['error'] > 0) {
        die('Upload file error, the code is: ' . $_FILES['upfile']['error']);
    }
    
    // 判断文件大小
    if ($_FILES["upfile"]["size"] > 50000) {
        die('The max size allowed is 50KB, your file is ' . $_FILES["upfile"]["size"] . 'KB');
    }
    
    $uploadType = $_FILES["upfile"]["type"];
    
    // 判断文件类型
    if (($uploadType == "image/gif") || ($uploadType == "image/jpeg") || ($uploadType == "image/pjpeg")) {
        if (is_uploaded_file($_FILES['upfile']['tmp_name'])) {
            if (move_uploaded_file($_FILES['upfile']['tmp_name'], 'uploads/' . 'abc.png')) {
                echo ('success');
            }
        } else {
            die('tmpFile error.');
        }
    } else {
        die('Only support the type of jpg,gif.');
    }
  • 相关阅读:
    easyui好例子,值得借鉴
    DDL 和DML 区别
    兼容IE的文字提示
    搭代理
    美国服务器
    跟随滚动条滚动
    JS Array对象
    JS 内置对象 String对象
    JS 对象
    JS 二维数组
  • 原文地址:https://www.cnblogs.com/shizqiang/p/4450604.html
Copyright © 2011-2022 走看看