def index4(request):
    if request.method == 'POST':
        student = StudentFrom(request.POST, request.FILES)
        if student.is_valid():
            handle_uploaded_file(request.FILES['file'])
            return HttpResponse("File uploaded successfuly")
    else:
        student = StudentFrom()
        return render(request, "index.html", {'form': student})
Beispiel #2
0
def index11(request):
    if request.method == 'POST':
        student = StudentForm(request.POST, request.FILES)
        if student.is_valid():
            handle_uploaded_file(request.FILES['file'])
            return HttpResponse("File Uploaded succesfully")
    else:
        student = StudentForm()
        return render(request, 'index2.html', {'form': student})
def file_upload(request):
    if request.method == 'POST':
        student = StudentForm(request.POST, request.FILES)
        if student.is_valid():
            handle_uploaded_file(request.FILES['file'])
            return HttpResponse("File uploaded successfully")
        else:
            return HttpResponse(
                "<h1>Value Error! Please check the values in fields!</h1>")
    else:
        student = StudentForm()
        return render(request, "index.html", {'form': student})
Beispiel #4
0
def home(request):
    flag = False
    if request.method == 'POST':
        file_uploads = FileUpload(request.POST, request.FILES)
        if file_uploads.is_valid():
            handle_uploaded_file(request.FILES['files'])
            flag = True
            context = {
                'data': flag,
                'msg': 'File Uploaded Successfully.',
                'link1': request.FILES['files'].name.split('.')[0] + '/part1/',
                'link2':
                request.FILES['files'].name.split('.')[0] + '/part2and3/',
            }

            return render(request, "output.html", context=context)
    else:
        file_uploads = FileUpload()
        context = {
            'data': flag,
            'form': file_uploads,
        }
        return render(request, "home.html", context=context)