Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Changing model field names for file #17

Closed
mrbm opened this issue Oct 5, 2012 · 1 comment
Closed

Changing model field names for file #17

mrbm opened this issue Oct 5, 2012 · 1 comment

Comments

@mrbm
Copy link

mrbm commented Oct 5, 2012

Having a little trouble following the javascript code. I wanted to create an additional field in the model called: file_2

Then before uploading the file, have the javascript detect if the file is not an image.

If it is an image it uploads the file to the normal file field.
// file = ImageWithThumbsField(upload_to='filefolder', sizes=((75,75),(120,120)), null=True, blank=True)

If the file being uploaded is not an image, then it would use file_2
// file_2 = models.FileField(upload_to='filefolder', null=True, blank=True)

ImageWithThumbsField is working and I can see how detect for an image...just having trouble seeing how the javascript would change the file field name parameter to file_2

Thanks!

@sigurdga
Copy link
Owner

Why not do that file checking server side? You should always check your file contents server side, so why not do it there only?

I use the "magic" (python-magic) module to check file contents.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants