def add_images(request): """ Adds a global images. """ if request.method == "POST": for file_content in request.FILES.getlist("file"): image = Image(title=file_content.name) try: image.image.save(file_content.name, file_content, save=True) except Exception, e: image.delete() logger.info("Upload of image failed: %s %s" % (file_content.name, e)) continue
def add_images(request): """ Adds a global images. """ if request.method == "POST": for file_content in request.FILES.getlist("files[]"): image = Image(title=file_content.name) try: image.image.save(file_content.name, file_content, save=True) except Exception as e: image.delete() logger.info("Upload of image failed: %s %s" % (file_content.name, e)) continue result = json.dumps({ "name": file_content.name, "type": "image/jpeg", "size": "123456789" }) return HttpResponse(result, content_type='application/json')