我有以下脚本,当它运行时我收到有关严格标准的错误,有人可以提供帮助吗?我试图将当前时间戳设置为文件名也是如此。
<br /> <b>Strict Standards</b>: Only variables should be passed by
reference in
<b>/home/user/public_html/domain.com/upload.php</b>
on line <b>15</b><br /> Upload: screenshot-05.png<br />Type:
image/png<br />Size: 49.2109375 Kb<br />Stored in: uploads/1401352853
PHP
if(empty($_FILES['file'])) {
exit();
}
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpg" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/png" && $_FILES["file"]["size"] < 2500000 && in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Error: " . $_FILES["file"]["error"] . "<br />";
} else {
$unixtime = time();
$fname = 'uploads/'. $unixtime;
move_uploaded_file($_FILES["file"]["tmp_name"], $fname);
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $fname;
}
} else {
echo "Invalid file type";
}
编辑:第15行是 - &gt; $extension = end(explode(".", $_FILES["file"]["name"]));
答案 0 :(得分:1)
$bits = explode(".", $_FILES["file"]["name"]);
$extension = end($bits);