5 글 보임 - 1 에서 5 까지 (총 5 중에서)
-
글쓴이글
-
2023년 3월 20일 14:20 #72925
이형민참가자악기 <select class="instrument form-select" aria-label="Default select example"> <option selected>선택하기</option> <option value="select" selected>선택하기</option> <option value="piano">피아노</option> <option value="acoustic-guitar">어쿠스틱 기타</option> <option value="drum">드럼</option> <option value="electronic-guitar">일렉기타</option> <option value="synthesizer">신디사이저</option> <option value="string-instrument">현악기</option> <option value="wind-instrument">관악기</option> <option value="gugak instrument">국악기</option> </select> 이러한 코드에서 셀렉터에서 선택된 값을 파이어스토어에 저장하려고 instrument0: document.getElementById("#instrument").val(), 이렇게 코드를 짰습니다. 저장이 안되는데 어떻게 코드를 짜야하나요?
2023년 3월 21일 09:52 #73043
이형민참가자$('#send').click(function () { alert('잠시만 기다려주세요.')
var file1 = document.querySelector('#image').files[0]; var storageRef = storage.ref(); var 저장경로 = storageRef.child('image/' + file1.name + 내uid); var 업로드 = 저장경로.put(file1)
var file2 = document.querySelector('#bgm').files[0]; var storageRef = storage.ref(); var 저장할경로 = storageRef.child('bgm/' + file2.name + 내uid); var 업로드작업 = 저장할경로.put(file2)
업로드작업.on('state_changed', // 변화시 동작하는 함수 null, //에러시 동작하는 함수 (error) => { console.error('실패사유는', error); }, // 성공시 동작하는 함수 () => { 업로드.snapshot.ref.getDownloadURL().then((url1) => { console.log('이미지 업로드 경로', url1);
업로드작업.snapshot.ref.getDownloadURL().then((url2) => { console.log('Bgm 업로드 경로', url2);
var 저장할거 = { title0: $('#title').val(), content0: $('#content').val(), mood0: document.getElementById("#mood").value, genre0: document.getElementById("#genre").value, instrument0: document.getElementById("#instrument").value, theme0: document.getElementById("t#heme").value, tempo0: document.getElementById("#tempo").value, vocal0: document.getElementById("#vocal").value, price0: parseInt($('#price').val()), date0: new Date(), image0: url1, bgm: url2, uid: JSON.parse(localStorage.getItem('user')).uid, name0: JSON.parse(localStorage.getItem('user')).displayName } db.collection('product').add(저장할거).then((result) => { console.log(result); alert('업로드가 완료되었습니다.'); window.location.href = "market.html"; }).catch((err) => { console.log(err) }) }); });
} );
})
이렇게 코드를 작성했는데, 업로드 버튼을 눌러보면 upload.html:296 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'value') 이런 오류를 띄웁니다 at upload.html:296:72
-
글쓴이글
5 글 보임 - 1 에서 5 까지 (총 5 중에서)
- 답변은 로그인 후 가능합니다.