webRTCで、 フロントエンドでユーザーのカメラにアクセスして、画像をdjangoにPOSTで送りたいです。
下記のコードで POSTしようとすると、 unknown url '' とエラーが出ます。
index.htmlでのフォームの書き方が間違えているのでしょうか?
エラー場所が値の受け取り場所なので、送信もとのjava scriptかFormを作成してるhtmlだと思うのですが、javascriptはいろんなコードを試したのですが、解決しません。
お力をお貸しください。
python
1 2 <form method="POST" name="inputForm" text="" enctype='multipart/form-data'> 3 {% csrf_token %} 4 <div id="camera" class="camera"> 5 <video id="video">Video stream not available.</video> 6 <button id="startbutton" type="button">Take photo</button> 7 <input id="webimg" name="src" type="text" style="display: none;"> 8 <canvas id="canvas"> 9 </canvas> 10 </div> 11 <br> 12 <div> 13 <img id="photo" alt="your image"> 14 </div> 15 <br> 16 <button type="submit" class="button" id="submit">Submit</button> 17 </form>
python
1 2def image_upload(request): 3 context = dict() 4 if request.method == 'POST': 5 username = request.POST.get('username') 6 7 webimg = urlopen(request.POST["src"]) 8
python
1function takepicture() { 2 // var context = canvas.getContext('2d'); 3 var context = canvas.getContext('2d'); 4 if (width && height) { 5 canvas.width = width; 6 canvas.height = height; 7 context.drawImage(video, 0, 0, width, height); 8 9 var data = canvas.toDataURL('image/png'); 10 photo.setAttribute('src', data); 11 } else { 12 clearphoto(); 13 } 14 }

あなたの回答
tips
プレビュー