各位高手都过来看一下,这个问题不知道是什么地方出错了。。。
我写了一个简单的上传文件程序:上传页面(upload.php):
<html>
<head>
<title>上传文件</title>
</head>
<body>
<script language="javascript">
function filecheck(form1){
if(form1.file1.value=""){
alert("上传文件为空,请重新选择文件!");
form1.file1.focus();
}
form1.submit();
}
</script>
<form enctype="multipart/form-data" name="form1" method="post" action="handleul.php">
<input type="file" name="file1" >
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input type="submit" name="submit" value="提交" onclick="filecheck(form1)">
</form>
</body>
</html>
处理文件(handleul.php):
<?php
include("./conn/conn.php");
$filename =$_FILES['file1']['name'];
$path ="./upfiles/".$_FILES['file1']['name'];
$date =date("Y-m-d");
if(!$file1=""){
if(copy($_FILES['file1']['tmp_name'],$path)){
$exec = "insert into uploadfile(file_name) values('$filename')";
$result=mysql_query($exec); //这个地方始终出错
if($result){
echo "上传成功!";
echo "<meta http-equiv=\"Refresh\" content =\"3;url=upload.php\">";
}else{
echo"上传失败!";
echo "<meta http-equiv =\"Refresh\" content =\"3; url=upload.php\">";
}
}
}
?>
数据库连接没问题,我怀疑是不是数据库中字段的类型错误,但试了n次都没结果,求高手指点!万分感激!