# rename and resize file before uploading

**URL:** <https://forum.djangoproject.com/t/rename-and-resize-file-before-uploading/3177>\
**Category:** Using Django\
**Created:** [June 27, 2020, 9:53pm UTC](https://forum.djangoproject.com/t/rename-and-resize-file-before-uploading/3177 "2020-06-27T21:53:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![openedsky](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/openedsky/32/1184_2.png) [@openedsky](https://forum.djangoproject.com/u/openedsky)\
**Post date:** [June 27, 2020, 9:53pm UTC](https://forum.djangoproject.com/t/rename-and-resize-file-before-uploading/3177/1 "2020-06-27T21:53:43Z")

</div>

```
piece_demandeur = request.FILES['piece']
fs = FileSystemStorage(location='media/demande-upload/')
filename = fs.save(piece_demandeur.name, piece_demandeur)

```

Hi,

I use this code in my views for uploading file with a model form. It works correctly But I would like to know how to rename and decrease size file (if file is greater than 200 Ko) before uploading.

I need your help.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 28, 2020, 12:11am UTC](https://forum.djangoproject.com/t/rename-and-resize-file-before-uploading/3177/2 "2020-06-28T00:11:04Z")

</div>

Django can’t do anything like this because Django doesn’t have the file until after it’s uploaded.

It _might_ be possible to find some JavaScript that _may_ be able to do this in the browser - but from what I know of the upload process, I kind of doubt it. (In either case, this isn’t a Django issue.)

Ken
