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

 

posted on 2017-12-25 20:20  大牛李  阅读(1474)  评论(0编辑  收藏  举报

导航