1 Introduction:
In the previous article, the blog introduced how to build your own user login registration system based on Dragonboard 410c with Python's django architecture. Today we will introduce separately how to enable users to upload their own videos to the server.
2. Tools:
Figure 1 Dragonboard410c
Figure 2 display
Figure 3 mouse keyboard
Figure 4 Smartphone
Second, the main codeMain html
2.view.py
From django.shortcuts import render
From django.shortcuts import render,render_to_response
From django.http import HttpResponse, HttpResponseRedirect
From django.template import RequestContext
From django import forms
Import os
Def videosave(request):
If request.method == "POST":
f = request.FILES.get('fileField')
baseDir = os.path.dirname(os.path.abspath(__name__))
Jpddir = os.path.join(baseDir,'static','jpg')
Print('f.name =',f.name)
Filename = os.path.join(jpgdir,f.name)
Fobj = open(filename,'wb')
For chrunk in f.chunks():
Fobj.write(chrunk)
Fobj.close()
Return render_to_response('video.html',{'fileField':f.name})
Else:
Return render_to_response('video.html')
Open your phone to access your designated service address, then click Browse to shoot, and finally click Upload, you can find the video or photo uploaded by your phone in your ~/Video/static/jpg directory. The following is the mobile page display:
Figure 5 main page
Figure 6 Click to select video / photo upload
Four.demo share:http://pan.baidu.com/s/1hrS21eO
Polycrystalline Solar Panel,160W Polysilicon Solar Panel,160W Solar Panel,Goal Zero Solar
Zhejiang G&P New Energy Technology Co.,Ltd , https://www.solarpanelgp.com