Currently trying to create a small file upload system similar to what was done here I've been trying to get my code to let the user upload any file from their local PC and then let it be copied to my server. albeit with no luck, the example I was following has examples up to 1.9 Django and I can't see much variation with that and 1.10. I've attached my views.py for the project currently the website i have will not upload any type of file and im not sure why
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.shortcuts import render
from django.core.urlresolvers import reverse
from .forms import docform
from .models import Document
def upload(request):
if request.method == 'POST':
form = docform(request.FILES)
if form.is_valid():
newdoc = Document (newfile=request.FILES['newfile'])
newdoc.save()
return HttpResponseRedirect(reverse('upload'))
else:
form = docform()
return render( request,'upload.html',)
Attaching upload.html
<!DOCTYPE html>
<html>
<head>
File upload system
</head>
<body>
<form action="{% url "upload" %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name=myfile" />
<p><input type="submit" value="upload"/></p>
</form>
</body>
</html>