我已經寫了一個PHP腳本來上傳文件。但是,當我按下提交按鈕它給出了一個錯誤消息:文件上傳中的嚴格標準錯誤
Strict Standards: Only variables should be passed by reference in H:\xampp\htdocs\phpTest\upload_file.php on line 4.
線4是$延長=結束( 「 」爆炸(,$ _FILES [「 文件 」] [「 名稱」]));
upload_file.php:
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
$target_Path = "images/";
$target_Path = $target_Path.basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $target_Path);
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"]/1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
echo $target_Path;
}
}
else
{
echo "Invalid file";
}
?>
我不知道爲什麼有人做downvoted這個問題....這是全部有效和不同的問題...解釋可以是什麼...提供的代碼...所以我投票這 – sandeepKumar 2012-08-06 04:53:28
接受答案,當它適用於你..所以,我們可以知道什麼是真實的錯誤 – sandeepKumar 2012-08-06 04:54:59
謝謝@SandeepKumar。我已經接受了答案,但我必須等待5分鐘才能做到這一點。 – user1559230 2012-08-06 04:59:09