我已经写了一个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