Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

file storage django

from django.shortcuts import render
from django.core.files.storage import FileSystemStorage


def image_upload(request):
    if request.method == "POST" and request.FILES["image_file"]:
        image_file = request.FILES["image_file"]
        fs = FileSystemStorage()
        filename = fs.save(image_file.name, image_file)
        image_url = fs.url(filename)
        print(image_url)
        return render(request, "upload.html", {
            "image_url": image_url
        })
    return render(request, "upload.html")
Comment

PREVIOUS NEXT
Code Example
Python :: how to convert string to datetime 
Python :: convert number to char python 
Python :: keras loss plot 
Python :: check if string match regex python 
Python :: seaborn 
Python :: flask where to put db.create_all 
Python :: string to list python 
Python :: python A string float numeral into integer 
Python :: modify a list with for loop function in python 
Python :: python3.8 
Python :: split by backslash python 
Python :: while loop in python 
Python :: how to convert pandas price column to integer 
Python :: count number of objects django template 
Python :: print binary tree python 
Python :: qt setfocus 
Python :: python doctype 
Python :: print output 
Python :: All Details in python stack 
Python :: sorting decimal numbers in python 
Python :: while python 
Python :: tkinter tutorial 
Python :: python area calculator 
Python :: import matplotlib sub 
Python :: plynomial regression implementation python 
Python :: python generate dictionary in loop 
Python :: pytorch multiply tensors element by elementwise 
Python :: faker, generates fake data for you 
Python :: tuple in python 
Python :: add list of dictionaries to pandas dataframe 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =