<?php
header("Content-Type: textml; charset=utf-8");
include_once ("../conn/conn.php");
$title=$_POST["title"];
$content=$_POST["content"];
$sc=$_FILES["up_file"]["name"];
$scc=$_FILES["up_file"]["tmp_name"];
$a=explode(".", $sc);
$b=array_pop($a);
$sccs=time().mt_rand();
$name=$sccs.".".$b;
$path='uploads/'.$name;
// echo $sc;echo $title;echo $content;
if ($_FILES["up_file"]["error"]==0) {
if (move_uploaded_file($scc, $path)) {
echo"上传成功";
// echo "<script>imgid=window.top.document.getElementById('imgid');
// imgid.src='{$path}'</script>";
}
else{
echo "错误2";
}
}
else{
echo "错误";
}
$sql="INSERT into test(title,content,src) values ('$title','$content','$path')"; //test是数据库表名
$r=mysqli_query($link,$sql);
if ($r){
echo "<script>alert('添加成功');window.location.href='page.html'</script>";
}else{
echo 201;
}
?>