upload image in django code example

Example 1: how to upload image in html

<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="image/*">
  <input type="submit">
</form>

Example 2: image in django

<html>
    <head>
       {% load staticfiles %} <!-- Prepare django to load static files -->
    </head>
    <body>
        <img src={% static "image.jpg" %}>
    </body>
</html>

Example 3: where we can store image in django project to so that t can work in html file

{% load static %}
<img src="{% static 'my_app/example.jpg' %}" alt="My image">

Example 4: how to upload image in php

<!DOCTYPE html><html><body><form action="upload.php" method="post"
enctype="multipart/form-data">    Select image to upload:    <input type="file" name="fileToUpload" id="fileToUpload">    <input type="submit" value="Upload Image" name="submit">
</form></body></html>

Tags: