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 关注
- 76 浏览
添加回答
举报
0/150
提交
取消