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";
    }
    }
    }
    ?>

  • 相关阅读:
    Win32的开发过程
    Win32的开发过程
    内存模式
    在DOS下生成一个可执行文件一般步骤
    内存模式
    内存模式
    静态链接
    在DOS下生成一个可执行文件一般步骤
    备忘录模式(存档模式)
    建造者模式
  • 原文地址:https://www.cnblogs.com/lichangqing1997/p/8111038.html
Copyright © 2011-2022 走看看