Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8115899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:36:51+00:00 2026-06-06T03:36:51+00:00

form html: <form action=’/register/’ method = ‘post’>{% csrf_token %} … <label>Avatar: </label><input type=’file’ name=’avatar’

  • 0

form html:

<form action='/register/' method = 'post'>{% csrf_token %}
    ...
    <label>Avatar: </label><input type='file' name='avatar' value='' /><br />
    <input type = 'submit' name='submit' value='Sign up' />
</form>

models.py

class Employee(models.Model):
    ...
    avatar = models.ImageField(upload_to = 'avatar', blank = True, null = True)
    ...

and views.py

def register(request):
    success = False
    message = ''
    try:
        newE = Employee.objects.create(...
                                avatar = request.POST['avatar'])
        success = True
        message = 'Register successful!'
        return HttpResponse(json.dumps({'success':str(success).lower(), 'message':message}))
    except:
        Employee.objects.filter(email = request.POST['email']).delete()
        message = 'Can\'t create a new account!'
        return HttpResponse(json.dumps({'success':str(success).lower(), 'message':message}))

settings.py

MEDIA_ROOT = '/home/dotcloud/data/media/'
MEDIA_URL = '/media/'

when I use the django admin page, the image will load and save:
http://training-hongquan156.dotcloud.com/media/avatar/image.png
but when I use html form upload photos, the image is not uploaded and saved in the folder ‘avatar‘, but saves the path:
http://training-hongquan156.dotcloud.com/media/image.png
and i can’t load image…
what’s problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:36:54+00:00Added an answer on June 6, 2026 at 3:36 am

    You should correct

    <form action="/register/" method="post">
    

    to

    <form action="/register/" enctype="multipart/form-data" method="post">
    

    handle the uploaded file with

    request.FILES['avatar']
    

    then find it in dir $upload_to,/home/dotcloud/data/media/photo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML <form id=contact_form action=# name= method=POST> <label for=name>NAME</label> <input type=text name=name id=name class=contact_form_input />
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
My form.html <form id=search-form method=post action=. name=f> <p><label for=id_customer_type>Customer type</label> <select name=customer_type id=id_customer_type> <option
I have this html code: <form name=input action=html_form_action.asp method=post id=formID> Username: <input type=text name=user
A simple HTML form: <form enctype=application/x-www-form-urlencoded method=post action=/view/album/id/4><ol> <li class=no-padding><div class=element> <input type=hidden name=media
I have a post html form, and the action is index.php, which is the
i.e. - <form action=http://192.168.1.20/form_action.asp method=get> vs. ( without a specific handler, still valid html?
I dynamically draw checkboxes in my form: @using (Html.BeginForm(Action, Controller, FormMethod.Post, new { id=itemsList}))
I have a jsp with a submit based on the html:form action. <html:form action=/nextPath>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.