Questions tagged [django-uploads]

Django-uploads refers to how django handles file uploads

Django-uploads refers to how django handles file uploads

See also:

91 questions
57
votes
7 answers

How do you convert a PIL `Image` to a Django `File`?

I'm trying to convert an UploadedFile to a PIL Image object to thumbnail it, and then convert the PIL Image object that my thumbnail function returns back into a File object. How can I do this?
44
votes
5 answers

Django: Validate file type of uploaded file

I have an app that lets people upload files, represented as UploadedFiles. However, I want to make sure that users only upload xml files. I know I can do this using magic, but I don't know where to put this check - I can't put it in the clean…
Plasma
  • 2,369
  • 1
  • 29
  • 35
43
votes
2 answers

Django / file uploads permissions

I wrote a django app, but I have a little problem with the file permissions of the uploads files from a web form. Basically I can upload a .mp3 file but it always keep chmod 600. The container folder has chmod 775, and the umask is set to 022. I'm…
z3a
  • 1,014
  • 2
  • 11
  • 20
37
votes
12 answers

UnicodeEncodeError: 'ascii' codec can't encode character

When uploading files with non-ASCII characters I get UnicodeEncodeError: Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/ Exception Value: 'ascii' codec can't encode character u'\xf8' in position 78: ordinal not in range(128) See…
vorpyg
  • 2,505
  • 4
  • 25
  • 22
26
votes
3 answers

How to delete files from filesystem using post_delete - Django 1.8

I have a model - Product, which contains a thumbnail image. I have another model which contains images associated with the product - ProductImage. I want to delete both the thumbnail and the images from the server when the product instance is…
tim
  • 379
  • 2
  • 5
  • 14
13
votes
1 answer

Django uploading file not in MEDIA_ROOT path is giving me SuspiciousOperation error

I want to upload files to a path that is still in my django project, but in my MEDIA_ROOT path. When I try to do this I get a SuspiciousOperation error. Here are the paths as defined in my settings file: MEDIA_ROOT = os.path.join(os.path.dirname(…
imns
  • 4,996
  • 11
  • 57
  • 80
7
votes
4 answers

Display image from ImageField by means of form

prelude: Here's the simpliest way to display an ImageField. Lets assume I have 10 fields in my form and I don't wanna iterate over all of them in template.html just to check if it's an imageField and display it in a different way. I want to handle…
deathangel908
  • 8,601
  • 8
  • 47
  • 81
7
votes
2 answers

Where does django store temporary upload files?

I have a Django/uwsgi/nginx stack running on CentOS. When uploading a large file to django (1GB+), I expect it to create a temp file in /tmp and I should be able to watch it grow as the upload progresses. However, I don't. ls -lah /tmp doesn't show…
Tony Abou-Assaleh
  • 3,000
  • 2
  • 25
  • 37
6
votes
1 answer

Exception occurred processing WSGI script - IOError: failed to write data

I'm trying to save an image at the server side.I recieve it as base64 string so I decode it first and then save it in the database.However this failed, so I checked the server error log and I found the following error.log [Tue May 21 14:26:38…
omarsafwany
  • 3,695
  • 8
  • 44
  • 75
5
votes
2 answers

Attempted access to '/media/uploads/

I've problem with upload method on the admin/ urls: In my settings: # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/var/www/example.com/media/" MEDIA_ROOT = os.path.join(PROJECT_PATH, "media") # URL that…
4
votes
1 answer

Django Admin - Upload multiple images to multiple model objects in a single upload

I have a model that has close to 150K entries in the Database. Today, it's possible to upload an image for each entry separately, when editing that specific entry. We have a need to upload close to 4k image files, one for each entry, and I would…
Meny Issakov
  • 1,400
  • 1
  • 14
  • 30
4
votes
1 answer

Django Upload Image in specific folder without FileField or ImageField and MEDIAROOT

My App needs to upload different profile images in different folders inside the static folder. One more thing, I'm not using models, I just want to take the picture I choose in html input file and copy to the specific folder. Here is my folder tree.…
Sergio Mendez
  • 1,311
  • 8
  • 33
  • 56
4
votes
1 answer

How to add a file from a filefield in Django to urls and views?

I'm doing a Django project, and I have a model called Projects, in this model I have a FileField inwhich files get uploaded to /media/files/YEAR/MONTH/DATE/. settings.py: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL =…
cenh
  • 154
  • 13
3
votes
1 answer

Upload files in Django using Uploadify getting HTTP response code 403

I am trying to upload files in Django using Uploadify following this tutorial. I have carried out all the steps properly. In addition to that I have made a model where I store information regarding the files that are being uploaded. My template…
Sachin
  • 3,672
  • 9
  • 55
  • 96
3
votes
1 answer

Multiple images in django form with multiupload

I need to add multiple images in django form to one model. I did a research and for form outside of django I try to setup django-multiupload. My models.py: class Profile(models.Model): ... ... first = models.ImageField("first",…
1
2 3 4 5 6 7