我得到了錯誤,同時從tmp目錄移動到的位置......這裏是我的代碼未定義指數:TMP而從臨時移動文件位置
if(isset($_POST['upload']))
{
$name = $_POST['name'];
$album_id = $_POST['album'];
$file = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file_tmp = $_FILES['file']['tmp'];
$random_name = rand();
if(empty($name) || empty($file))
{
echo "Please fill all the fields";
}
else
{
move_uploaded_file($file_tmp, 'uploads/'.$random_name.'.jpg');//Error in this line
mysqli_query($con,"INSERT INTO `p_photos` (`name`,`album_id`,`url`) VALUES ('$name','$album_id','$random_name.jpg')");
echo 'Photo Uploaded successfully!<br /><br />';
}
}
哪裏我做錯....是有一個文件夾「上傳」
的**未定義指數**錯誤將來自試圖訪問索引['tmp'],如在這條線:'$ file_tmp = $ _FILES [ '文件'] [ 'TMP'];'。檢查以確保'$ file_tmp'被正確定義。 –
是的,我們正確。我哪裏做錯了? – shaiToro
http://php.net/manual/en/features.file-upload.php –