I cannot show a file-upload button

lili

I cannot show a file-upload button. I wrote in profile.html like

{% extends "registration/accounts/base.html" %}
{% block content %}
user.username: {{ user.username }}<hr>
user.is_staff: {{ user.is_staff }}<hr>
user.is_active: {{ user.is_active }}<hr>
user.last_login: {{ user.last_login }}<hr>
user.date_joined: {{ user.date_joined }}
{% endblock %}

<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>UPLOAD</title>


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>

{% block body %}
<div class="container">
  <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
    <input type="file" name="files[]" multiple>
    <input type="hidden" value="{{ p_id }}" name="p_id">
    {% csrf_token %}
    <input type="submit">
  </form>
</div>
{% endblock %}

   <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>


  </body>
</html>

So,I wrote multipart/form-data tag like

 <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">.

But, profile.html did not show the part of ~ .

it showed only {% extends "registration/accounts/base.html" %} ~ {% endblock %}.

How can i fix it?

Prakhar Trivedi

Placing and position of {% block content %} is wrong in your code. There are several issues with your code and I removed them. You dont need an extra {% block body %}. So you should use this code instead :

  {% extends "registration/accounts/base.html" %}
  {% block content %}

  <!DOCTYPE html>

  <html lang="ja">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>UPLOAD</title>
    </head>
    <body>
    user.username: {{ user.username }}<hr>
    user.is_staff: {{ user.is_staff }}<hr>
    user.is_active: {{ user.is_active }}<hr>
    user.last_login: {{ user.last_login }}<hr>
    user.date_joined: {{ user.date_joined }}

    <div class="container">
      <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <input type="file" name="files[]" multiple>
        <input type="hidden" value="{{ p_id }}" name="p_id">
        <input type="submit" value="Upload">
      </form>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    </body>
  </html>

  {% endblock %}

Also Note that, Place the csrf_token in correct position and add value="Upload" to input type="submit" .

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony VichUploader : Cannot see file button to upload

From Dev

Is that possible upload file when i m click on browse button in plupload?

From Dev

Cannot upload file

From Dev

Cannot upload a file in proctractor

From Dev

Cannot upload a file with jersey

From Dev

Wordpress - Cannot upload file

From Dev

Cannot upload file to form

From Dev

File to upload and show on div multiple

From Dev

Styling The File Upload 'Browse' Button

From Dev

html form file upload button

From Dev

jQuery File Upload hooked to button

From Dev

File upload - show file name even though I hid it w/ JS

From Dev

How can I show two file upload buttons once I select a choice in a switch

From Dev

How can I show two file upload buttons once I select a choice in a switch

From Dev

Photo Upload to Google Drive via Android app+cannot exit app until i press home button

From Dev

Cannot upload a image file in the EPiServersite

From Dev

Cannot upload a image file in the EPiServersite

From Dev

Cannot upload file to server in PHP

From Dev

Cannot upload 'MOV' file in PHP

From Dev

Is it Possible to make a button as File upload Button?

From Dev

How to upload a filepath to local database and receive the file path when I click download button

From Dev

How could I validate the insert button if the user did not choose a file to upload?

From Dev

How do I upload multiple images and text file in a single form with the different button in Codeigniter?

From Dev

I cannot show several valuables when I use for loop at ect file as template on Node.js(express)

From Dev

Upload file with Fetch API in Javascript and show progress

From Dev

Show success/error message on dropzone file upload

From Dev

Show a progress on multiple file upload Jquery/Ajax

From Dev

Show file upload progress in Essence framework

From Dev

jQuery File Upload show time remaining?

Related Related

  1. 1

    Symfony VichUploader : Cannot see file button to upload

  2. 2

    Is that possible upload file when i m click on browse button in plupload?

  3. 3

    Cannot upload file

  4. 4

    Cannot upload a file in proctractor

  5. 5

    Cannot upload a file with jersey

  6. 6

    Wordpress - Cannot upload file

  7. 7

    Cannot upload file to form

  8. 8

    File to upload and show on div multiple

  9. 9

    Styling The File Upload 'Browse' Button

  10. 10

    html form file upload button

  11. 11

    jQuery File Upload hooked to button

  12. 12

    File upload - show file name even though I hid it w/ JS

  13. 13

    How can I show two file upload buttons once I select a choice in a switch

  14. 14

    How can I show two file upload buttons once I select a choice in a switch

  15. 15

    Photo Upload to Google Drive via Android app+cannot exit app until i press home button

  16. 16

    Cannot upload a image file in the EPiServersite

  17. 17

    Cannot upload a image file in the EPiServersite

  18. 18

    Cannot upload file to server in PHP

  19. 19

    Cannot upload 'MOV' file in PHP

  20. 20

    Is it Possible to make a button as File upload Button?

  21. 21

    How to upload a filepath to local database and receive the file path when I click download button

  22. 22

    How could I validate the insert button if the user did not choose a file to upload?

  23. 23

    How do I upload multiple images and text file in a single form with the different button in Codeigniter?

  24. 24

    I cannot show several valuables when I use for loop at ect file as template on Node.js(express)

  25. 25

    Upload file with Fetch API in Javascript and show progress

  26. 26

    Show success/error message on dropzone file upload

  27. 27

    Show a progress on multiple file upload Jquery/Ajax

  28. 28

    Show file upload progress in Essence framework

  29. 29

    jQuery File Upload show time remaining?

HotTag

Archive