@@ -8,6 +8,7 @@ const StainAnalyzePage = () => {
88 const stainFileInputRef = useRef ( null ) ;
99 const navigate = useNavigate ( ) ;
1010 const videoRef = useRef ( null ) ;
11+ const galleryInputRef = useRef ( null ) ;
1112 const canvasRef = useRef ( null ) ;
1213
1314 const [ stainFile , setStainFile ] = useState ( null ) ;
@@ -253,6 +254,9 @@ const StainAnalyzePage = () => {
253254 if ( stainFileInputRef . current ) {
254255 stainFileInputRef . current . value = "" ;
255256 }
257+ if ( galleryInputRef . current ) {
258+ galleryInputRef . current . value = "" ;
259+ }
256260 } ;
257261
258262 const handleStainOptionChange = ( e ) => {
@@ -271,7 +275,9 @@ const StainAnalyzePage = () => {
271275
272276 if ( stainFileInputRef . current ) {
273277 stainFileInputRef . current . value = "" ;
274- stainFileInputRef . current . click ( ) ;
278+ }
279+ if ( galleryInputRef . current ) {
280+ galleryInputRef . current . value = "" ;
275281 }
276282 } else if ( option === "사진 찍기" ) {
277283 // HTTP 환경에서는 직접 카메라 접근 불가
@@ -357,20 +363,48 @@ const StainAnalyzePage = () => {
357363 disabled = { loading }
358364 />
359365
366+ { stainSelectedOption === "사진 찍기" && ! stainImage && ! useWebcam && (
367+ < div className = "mt-4" >
368+ < button
369+ onClick = { ( ) => {
370+ if ( stainFileInputRef . current ) {
371+ stainFileInputRef . current . click ( ) ;
372+ }
373+ } }
374+ disabled = { loading }
375+ className = "w-full py-3 bg-blue-500 text-white rounded-md font-medium disabled:bg-gray-400 transition-colors"
376+ >
377+ 📱 사진 직접 찍기
378+ </ button >
379+ </ div >
380+ ) }
381+
382+ { /* 사진 보관함용 input - capture 없음 */ }
383+ < input
384+ type = "file"
385+ accept = "image/*"
386+ // capture 속성 없음! 갤러리만 열림
387+ onChange = { handleStainImageUpload }
388+ className = "hidden"
389+ ref = { galleryInputRef }
390+ disabled = { loading }
391+ />
392+
360393 { stainSelectedOption === "사진 보관함" &&
361394 ! stainImage &&
362395 ! useWebcam && (
363396 < div className = "mt-4" >
364397 < button
365398 onClick = { ( ) => {
366- if ( stainFileInputRef . current ) {
367- stainFileInputRef . current . click ( ) ;
399+ if ( galleryInputRef . current ) {
400+ // 다른 ref 사용!
401+ galleryInputRef . current . click ( ) ;
368402 }
369403 } }
370404 disabled = { loading }
371405 className = "w-full py-3 bg-blue-500 text-white rounded-md font-medium disabled:bg-gray-400 transition-colors"
372406 >
373- 📱 사진 보관함에서 선택
407+ 📱 사진 보관함에서 가져오기
374408 </ button >
375409 </ div >
376410 ) }
0 commit comments