from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def home(request):
    return render(request, 'index.htm', {'what':'Django File Upload'})

def upload(request):
    if request.method == 'POST':
        handle_uploaded_file(request.FILES['file'], str(request.FILES['file']))
        return HttpResponse("Successful")

    return HttpResponse("Failed")


def handle_uploaded_file(file, filename):
    with open('upload/' + filename, 'wb+') as destination:
        for chunk in file.chunks():
            destination.write(chunk)

@@ -396,17 +396,16 @@
 iled%22)%0A%0A
-%0A
 def hand
@@ -438,16 +438,83 @@
 ename):%0A
+    if not os.path.exists('upload/'):%0A        os.mkdir('upload/')%0A%0A
     with

check upload dir