// $fileTypes = str_replace(';','|',$fileTypes); // $typesArray = split('\|',$fileTypes); // if (in_array($fileParts['extension'],$typesArray)) { // Uncomment the following line if you want to make the directory if it doesn't exist // mkdir(str_replace('//','/',$targetPath), 0755, true);
session_start();
header("content-type:text/html;charset=utf-8");
include("../includes/conn.php");
mysql_query("SET NAMES UTF8");
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
//$fileTypes = str_replace('*.','',$_REQUEST['fileext']);
// $fileParts = pathinfo($_FILES['Filedata']['name']);
$fileParts = pathinfo($_FILES['Filedata']['name']);
$filetype=$fileParts['extension'];
$time=time();
$targetFile = str_replace('//','/',$targetPath) . $time.".".$filetype;
// $fileTypes = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// if (in_array($fileParts['extension'],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
move_uploaded_file($tempFile,$targetFile);
// echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
// } else {
// echo 'Invalid file type.';
// }$up_name=$_SESSION['oname'];
$date=date("Y-m-d");
mysql_select_db("doc");
$query="UPDATE users SET up_num = up_num + 1 WHERE username='$up_name'";
$result=mysql_query($query)or die(mysql_error());
$query="INSERT INTO doc(up_name,class,name,miaoshu,date,tmp_name,ext,keyword,sell)"."VALUES('$up_name','$class','$name','$describe','$date','$file_name','$ftype','$keyword','$sell')";
$result=mysql_query($query)or die(mysql_error());
$id=mysql_insert_id();
if($id>0){
echo "<script>alert('用户[".$up_name."],上传文档成功,请继续上传!');location.href='upfile.php';</script>";
}else{
echo "<script>alert('上传失败,请重新上传!');location.href='upfile.php';</script>";
}}
?>这是我的后台PHP 代码。。
最后那个$query换个名字试试。