16 lines
516 B
Python
16 lines
516 B
Python
from django.shortcuts import render
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
|
|
|
def 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")
|