웹뷰에서 파일 멀티 선택은 어떻게 하나요?
본문
그누보드 게시판 첨부를 아래와 같이 멀티로 첨부파일 업로드 할수 있게 했습니다.폰에서 크롬이나 오페라에서 멀티로 선택해서 첨부 됩니다.<input multiple="multiple" type="file" name="bf_file[]" title="" class="frm_file frm_input">웹뷰에서는 하나씩만 첨부가 되네요. 멀티 선택해서 올리려면 어떻게 하나요?
웹뷰에서 아래와 같이했습니다. 하나만 선택 되네요 ㅠㅠ
publicvoidopenFileChooser( ValueCallback<uri> uploadMsg) { Log.d("MainActivity", "3.0 <"); openFileChooser(uploadMsg, ""); } // For Android 3.0+ publicvoidopenFileChooser( ValueCallback<uri> uploadMsg, String acceptType) { Log.d("MainActivity", "3.0+"); filePathCallbackNormal = uploadMsg; Intent i = newIntent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_NORMAL_REQ_CODE); } // For Android 4.1+ publicvoidopenFileChooser(ValueCallback<uri> uploadMsg, String acceptType, String capture) { Log.d("MainActivity", "4.1+"); openFileChooser(uploadMsg, acceptType); } // For Android 5.0+ publicbooleanonShowFileChooser( WebView webView, ValueCallback<uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { Log.d("MainActivity", "5.0+"); if(filePathCallbackLollipop != null) { filePathCallbackLollipop.onReceiveValue(null); filePathCallbackLollipop = null; } filePathCallbackLollipop = filePathCallback; Intent i = newIntent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_LOLLIPOP_REQ_CODE); returntrue; }---------------------------------------------------------------------------------
protectedvoidonActivityResult(intrequestCode, intresultCode, Intent data) { if(requestCode == FILECHOOSER_NORMAL_REQ_CODE) { if(filePathCallbackNormal == null) return; Uri result = (data == null|| resultCode != RESULT_OK) ? null: data.getData(); filePathCallbackNormal.onReceiveValue(result); filePathCallbackNormal = null; } elseif(requestCode == FILECHOOSER_LOLLIPOP_REQ_CODE) { if(filePathCallbackLollipop == null) return; filePathCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data)); filePathCallbackLollipop = null; }}
답변을 작성하시기 전에 로그인 해주세요.