Image Upload

 Image Uploading

1) File upload to the server using Django is a very easy task. Django provides built-in library and methods that help to upload a file to the server.
2) The models.ImagesFields() method is used to create a file input and submit the file to the server. While working with files, make sure the HTML form tag contains enctype="multipart/form" property.
3) The very first step is to add below code in the settings.py file.
    MEDIA_ROOT=os.path.join(BASE_DIR,'media')
    MEDIA_URL='/media/'
4) MEDIA_ROOT is for server path to store files in the computer.
5) MEDIA_URL is the reference URL for browser to access the files over Http.
6) In the urls.py we should edit the configuration like this
from django.conf import settings
from django.conf.urls.static import static
if settings.DEBUG:
        urlpatterns+=static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)


#index.html
#models.py
#view.py
#show.html
#urls.html
Output=1



Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!