好吧,我试图上传一个类别为tittle和description的图片,但是没有用,请帮帮我。我的代码是。
if(isset($_POST['save']))
{
//for getting the file type
echo $_FILES['file']['type'];
//verifying the images
if($_FILES['file']['type']=='image/jpeg' || $_FILES['file']['type']=='image/png'|| $_FILES['file']['type']=='image/gif' && $_FILES['file']['size']>0)
{
//protecting from injection somewhat
$category=mysql_real_escape_string($_POST['category']);
$category=stripslashes($category);
$tittle=mysql_real_escape_string($_POST['tittle']);
$tittle=stripslashes($tittle);
$description=mysql_real_escape_string($_POST['description']);
$description=stripslashes($description);
//storing file in filename variable
$fileName = $_FILES["file"]["name"];
//destination dir
$to="file/".$fileName;
if(move_uploaded_file($_FILES['file']['tmp_name'],$to))
{
if($query=mysql_query("INSERT INTO `soft_upload_category`(`id`, `soft_tittle`, `soft_url`, `soft_category`, `soft_description`) VALUES(NULL,'".$tittle."','".$to."','".$category."','".$description."');"))
{
echo '<script type="text/javascript">alert("Successfully Uploaded")</script>' ;
}
else{ echo '<script type="text/javascript">alert("Sorry Couldnt Move the File")</script>' ; }
}
else{'couldnt upload the file';}
}
else { echo '<script type="text/javascript">alert("Please Choose only the Image files")</script>' ; }
}
?>
当我按下保存按钮时,它会给我一个错误:
else{ echo '<script type="text/javascript">alert("Sorry Couldnt Move the File")</script>' ; }