function processImages($images){$uploadfiles = array();// make sure images array does not contain more than 3 imagesif (count($images) <= 3) { foreach ($images as $image) { $uploadfile = "NULL"; if ($image['size'] != 0) { //file process function doFileCheck($file, $image) { $imginfo_array = getimagesize($file); /*getimagesize() only works with imagesif getimagesize() fails it will returnfalse you can use var_dump() to see insidethe array.echo var_dump($imginfo_array) */ if ($imginfo_array !== false) { $uploaddir = './uploads/'; $uploadfile = $uploaddir . basename($image['name']); if (file_exists($uploadfile)) { echo "<h3>That filename already exists - try again!</h3>"; } else { if (move_uploaded_file($image['tmp_name'], $uploadfile)) { echo "<h3>File seems valid, and was successfully uploaded</h3>"; } else { echo "INVALID! Possible file upload attack!\n"; } } return $uploadfile; } }我有這個文件處理函數,問題是我得到一個異常,說只有變量應該通過引用傳遞。在第一種情況下,它會在 switch 語句中引發該異常,因為我正在嘗試上傳 jpeg 圖像,但我正在調試它并且找不到問題。我將一個數組傳遞給包含表單中每個文件(總共 3 個)的函數,然后遍歷文件以處理每個文件
1 回答

胡子哥哥
TA貢獻1825條經驗 獲得超6個贊
閱讀有關array_push()的更多信息。
您正在傳遞 adoFileCheck($file, $image)
而不是$array_of_vars
and $new_element_in_array_of_vars
。
BTW$array_of_vars[] = $new_element_in_array_of_vars;
的工作速度比array_push($array_of_vars,$new_element_in_array_of_vars);
.
- 1 回答
- 0 關注
- 118 瀏覽
添加回答
舉報
0/150
提交
取消