zoukankan      html  css  js  c++  java
  • php文件上传 form表单形式

    1.php界面

    <?php
    header( 'Content-Type:text/html;charset=utf-8 ');
    include_once("conn/conn.php");
    $t_name=$_FILES["files"]["tmp_name"];
    $name=$_FILES["files"]["name"];
    $a=explode(".", $name);
    $b=array_pop($a);
    $title=$_POST["title"];
    $keywords=$_POST["keywords"];
    $content=$_POST["content"];
    $names=time().mt_rand();
    $true_name=$names.".".$b;

    $path='uploads/'.$true_name;
    if(!empty($_FILES["files"]["error"]==0)){

    if(move_uploaded_file($t_name,$path)){
    $sql="insert into a1(title,keywords,content,files)values('$title','$keywords','$content','$name')";
    $r=mysqli_query($link,$sql);
    if($r){
    echo "aaa";
    }else{
    echo "bbb";
    }
    }
    }
    ?>

    upload.php界面

    <?php
    header( 'Content-Type:text/html;charset=utf-8 ');
    include_once("conn/conn.php");
    $t_name=$_FILES["files"]["tmp_name"];
    $name=$_FILES["files"]["name"];
    $a=explode(".", $name);
    $b=array_pop($a);
    $title=$_POST["title"];
    $keywords=$_POST["keywords"];
    $content=$_POST["content"];
    $names=time().mt_rand();
    $true_name=$names.".".$b;

    $path='uploads/'.$true_name;
    if(!empty($_FILES["files"]["error"]==0)){

    if(move_uploaded_file($t_name,$path)){
    $sql="insert into a1(title,keywords,content,files)values('$title','$keywords','$content','$name')";
    $r=mysqli_query($link,$sql);
    if($r){
    echo "aaa";
    }else{
    echo "bbb";
    }
    }
    }
    ?>

  • 相关阅读:
    Semaphore使用
    不可变对象
    Java锁--Lock实现原理(底层实现)
    Lambda Expressions and Functional Interfaces: Tips and Best Practices
    注解的作用
    linux命令大全
    linux &和&&,|和||
    SpringCloud 商品架构例子(一)
    springcloud starter(一)
    dubbo(一)
  • 原文地址:https://www.cnblogs.com/lichangqing1997/p/8111038.html
Copyright © 2011-2022 走看看