在這裏我試圖在php中上傳jpeg,pdf,png和word文件格式。但我無法上傳pdf,png和word文件格式,但我已成功上傳jpeg文件格式。所以這是我嘗試過的代碼。請幫助編輯此代碼,以便將jpeg文件格式的其他文件格式上傳。在php中上傳pdf和word文件
<?php
include_once("db.php");
if(isset($_POST['save'])){
if(($_FILES['file']['type']=='pdf/pdf')
||($_FILES['file']['type']=='image/jpeg')
||($_FILES['file']['type']=='image/png')
&&($_FILES['file']['size']<200000))
{
if($_FILES['file']['error']>0)
{
echo"return code :".$_FILES['file']['error'];
}
//else if(file_exists('upload/'.$_FILES['file']['name']))
//{
//echo $_FILES['file'] ['name']."Already exite";
//}
else if(move_uploaded_file($_FILES['file'] ['tmp_name'],'upload/'.$_FILES['file']['name']))
{
$part =$_FILES['file']['name'];
$sql = mysql_query("INSERT INTO stu (ptype,source,letterno,title,descrip,receiver,image)
VALUES ('{$_POST['pt']}',
'{$_POST['so']}',
'{$_POST['ln']}',
'{$_POST['lti']}',
'{$_POST['dic']}',
'{$_POST['re']}',
'{$part}')");
//$sql= "INSERT INTO stu (ptype,source, letterno, title,descrip,receiver,image) VALUES ('$p', '$s', '$l', '$t','$d','$r','$part')";
if ($sql){
echo"jhgjhgjh";
//echo "successfully insert thise record";
//echo "<script type='text/javascript'>alert('successfully insert thise record')</script>";
echo "<script type='text/javascript'>alert('successfully insert thise record')</script>";
}
}
}
}
?>
做當您嘗試上傳巴紐/ .DOC你能拿到什麼錯誤? – bIgBoY