2013-06-04 66 views
0

我對我的圖片上傳腳本PHP上傳腳本「只有變量應該傳遞」錯誤

SCREAM: Error suppression ignored for 
(!) Strict standards: Only variables should be passed by reference in    C:\wamp\www\Arede\upload.php on line 14 
Call Stack 
# Time Memory Function Location 
1 0.0003 262744 {main}() ..\upload.php:0 

這裏得到這個錯誤的腳本

<?php 
$allowedExts = array("gif", "jpeg", "jpg", "png"); 
$extension = end(explode(".", $_FILES["file"]["name"])); 
if ((($_FILES["file"]["type"] == "image/gif") 
|| ($_FILES["file"]["type"] == "image/jpeg") 
|| ($_FILES["file"]["type"] == "image/jpg") 
|| ($_FILES["file"]["type"] == "image/pjpeg") 
|| ($_FILES["file"]["type"] == "image/x-png") 
|| ($_FILES["file"]["type"] == "image/png")) 
&& ($_FILES["file"]["size"] < 2000000000000) 
&& in_array($extension, $allowedExts)) 
    { 
    if ($_FILES["file"]["error"] > 0) 
    { 
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; 
    } 
    else 
    { 
    echo "Upload: " . $_FILES["file"]["name"] . "<br>"; 
    echo "Type: " . $_FILES["file"]["type"] . "<br>"; 
    echo "Size: " . ($_FILES["file"]["size"]/1024) . " kB<br>"; 
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; 

if (file_exists("images/" . $_FILES["file"]["name"])) 
    { 
    echo $_FILES["file"]["name"] . " Já Existe "; 
    } 
else 
    { 
    move_uploaded_file($_FILES["file"]["tmp_name"], 
    "images/" . $_FILES["file"]["name"]); 
echo "<table align=\"center\" style=\"color:#FFF\"><tr align=\"center\"><td align=\"center\"> 
<img src=\"wp-content/uploads/2013/05/checkmark-green-3D-small.png\" width=\"17\"  height=\"16\" /><h3 style=\"color:#FFF; font:bold;\">Upload bem sucedido</h3> 
</td> 
</tr> 
</table> 

    "; 
     } 
    } 
    } 
else 
    { 
    echo "Invalid file"; 
    } 
?> 

它理應保存臨時文件和然後檢查是否有任何重複,如果沒有它應該將圖像保存爲「圖像/」我不知道爲什麼它說只有變量應該通過。 任何建議,將不勝感激 感謝

+0

和第14行是什麼? – 2013-06-04 20:53:37

回答

0

end命令需要一個變量引用您應該執行的爆炸,並將其分配給一個變量在調用end

$tmp = explode(".", $_FILES["file"]["name"]); 
$extension = end($tmp);