Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

FileSystemStorage django

if request.method == "POST":
    # if the post request has a file under the input name 'document', then save the file.
    request_file = request.FILES['document'] if 'document' in request.FILES else None
    if request_file:
            # save attached file
 
            # create a new instance of FileSystemStorage
            fs = FileSystemStorage()
            file = fs.save(request_file.name, request_file)
            # the fileurl variable now contains the url to the file. This can be used to serve the file when needed.
            fileurl = fs.url(file)
 
return render(request, "template.html")
Comment

PREVIOUS NEXT
Code Example
Python :: two underscores python 
Python :: database with python 
Python :: python read xlsx file 
Python :: xlabel not showing matplotlib 
Python :: python module has no attribute 
Python :: python xmlrpc 
Python :: Python DateTime Date Class Example 
Python :: python int to byte 
Python :: literal_eval in python 
Python :: open multiple plots python 
Python :: python reverse a list 
Python :: Python re.subn() 
Python :: boto 3 list EMR 
Python :: jupyter notebook not opening 
Python :: pip vs conda 
Python :: sample hierarchical clustering 
Python :: char list python 
Python :: pivot table but keep nan 
Python :: Python List clear() 
Python :: django prevent duplicate entries 
Python :: how to code a funtion in python 
Python :: import from parent directory python 
Python :: check if string is python code 
Python :: num2words python 
Python :: check if value is in series pandas 
Python :: how to split a string by colon in python 
Python :: split range python 
Python :: check if a value is in index pandas dataframe 
Python :: django middleware 
Python :: python floor float 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =