請幫助我,這裏是我的代碼:的文件是不是從臨時移動到文件夾上傳
if(isset($_POST['send'])) {
$filename =strtolower(basename($_FILES['resume']['name']));
$ext = $_FILES["resume"]["type"];
$size= $_FILES["resume"]["size"];
if (!empty($filename) && (($ext == "application/msword") ||
($ext == "application/pdf") && ($size < 500000))) {
$name = $_POST['name'];
$email_address = $_POST['email'];
$nwname=str_replace(" ","",$name);
$newfilename= substr(md5(rand() * time()),0,7);
$newfilename2 =$nwname."_".$newfilename;
if($ext == 'application/msword') {
$newname ='upload/'.$newfilename2.".doc";
} else if($ext == 'application/pdf'){
$newname ='upload/'.$newfilename2.".pdf";
}
$temp= $_FILES['resume']['tmp_name'];
echo $temp;
$move = @move_uploaded_file($temp,$newname)
or die('Updoaling error.');
echo $move;
$query = mysql_query("UPDATE saxet SET filelocation='$newname'
WHERE name='$name' AND email='$email_address'");
}
}
我的名稱爲「$filename
」沒有移動到臨時文件夾中的文件。可以幫助我嗎?
從顯示錯誤消息開始並從調用move_uploaded_file中刪除'@' –
刪除@move_uploaded_file($ temp,$ newname)中的@以查看錯誤(如果有)。 – Adam
可能有這麼多的可能性..但要檢查,你可以echo $ temp和$ newname。如果他們正確地來了,那麼你的代碼應該工作。也刪除@從move_uploaded_file –