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; } }我有這個(gè)文件處理函數(shù),問(wèn)題是我得到一個(gè)異常,說(shuō)只有變量應(yīng)該通過(guò)引用傳遞。在第一種情況下,它會(huì)在 switch 語(yǔ)句中引發(fā)該異常,因?yàn)槲艺趪L試上傳 jpeg 圖像,但我正在調(diào)試它并且找不到問(wèn)題。我將一個(gè)數(shù)組傳遞給包含表單中每個(gè)文件(總共 3 個(gè))的函數(shù),然后遍歷文件以處理每個(gè)文件
1 回答

胡子哥哥
TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
閱讀有關(guān)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 關(guān)注
- 116 瀏覽
添加回答
舉報(bào)
0/150
提交
取消