""" Created on Jan 7, 2012 @author: tgdn """ import json def upload(request): """ This snippet should be used with javascript file-uploader from Andrew Valums ( andrew(at)valums.com ) http://github.com/valums/file-uploader """ # should be an ajax request if request.is_ajax(): # Get image from raw data image = request.raw_post_data # The original filename name = request.GET.get('qqfile', 'some_name') # Where to upload the file url = '%s/uploads/%s' % (settings.MEDIA_ROOT, name) # Writing image to 'url' directory destination = open(url, 'wb+') destination.write(image) destination.close() """ If you want to save the image in a database do like this: (according that 'Image' is the image model) *models.py* from django.db import models class Image(models.Model): image = models.ImageField(upload_to='uploads') --- And right after the image writing above: image = Image(image="uploads/%s" % name) image.save() """ output = { 'success': True } return HttpResponse(json.dumps(output))