PHP 多檔案上傳

name 設為[]陣列 ,並在後方加上 multiple

<input type="file" name="userImage[]" id="userImage" multiple>

上傳處理

foreach( $_FILES[userImage][tmp_name] AS $k => $v){
	if(is_uploaded_file($_FILES['userImage']['tmp_name'][$k])) {
		$source_file = $_FILES['userImage']['tmp_name'][$k];
		$target_file = date( "Ymd.His").'_'.$_FILES['userImage']['name'][$k];
		if(move_uploaded_file($source_file,$target_file)) {
			echo $source_file.'上傳成功';
		}
	}
}