user15317824
user15317824

Reputation: 470

get the size of an image to be uploaded in django before the upload process starts

Okay, I don't have a code snippet here, I wanted to display a progress bar when I am uploading an image in Django, am using celery and some other stuff, but most importantly i will need to know the size of the file been uploaded so that I can compute the progress of the upload, any suggestion or solutions, please.

Upvotes: 0

Views: 151

Answers (1)

Allaye
Allaye

Reputation: 950

def file_upload(request):
    if request.method == 'POST' and request.FILES['filename']:
        file = request.FILES['file']
        print(file.size)
        # do whatever you want here
    return render(request, 'file_upload.html')

Upvotes: 1

Related Questions