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 8793261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:06:01+00:00 2026-06-13T23:06:01+00:00

although, there are many topics for this, i cannot find the right question+answer among

  • 0

although, there are many topics for this, i cannot find the right question+answer among them
my problem is this:

i am trying to write an file upload. once i submit the form, this error is coming:

MultiValueDictKeyError at /anzeige_save/
Key 'file' not found in <MultiValueDict: {}>

this is my model:

class Anzeige(models.Model):
    titel = models.CharField(max_length=300)
    anzeige = models.CharField(max_length=1000)
    date = models.DateTimeField()
    datum = models.CharField(max_length=12)
    file = models.FileField(upload_to='/anzeige/D-d-M-Y/')
    def __unicode__(self):
        return self.titel

this is my view:

if request.path == '/anzeige_save/':
    anzeige=Anzeige(titel=request.POST['titel'], anzeige=end_anzeige,date=datetime.datetime.now(), datum=request.POST['datum'],file=request.FILES['file'])
    anzeige.save()
    return HttpResponse("Anzeige saved successfully")

this is my ajax in front-end:

var title = document.getElementById(title).value;
var body = document.getElementById(body).value;
var file = document.getElementById(name_file).value;
var datum = document.getElementById(datum).value;
if(title==" " || body==" " || title=="" || body=="" || datum=="" || datum==" " ){
alert("Please fill out all!");
}else{
    $.ajax({
    url: "/anzeige_save/",
    type: "POST",
    data: {anzeige:body,titel:title,file:file,datum:datum},
}).success(function(data){
    $(succ_message).text(data);
    $(succ_message).fadeIn(1000);
    $(succ_message).fadeOut(2000);
})
 }

and this is file in form:

...
<input type="file" id="name_file" name="name_file" size="40" maxlength="100000"><br />
...

am i missing something here ?

i have Model with filefield and i am saving other fields including file into instance.

thanks for any drop-by! 🙂

  • 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-13T23:06:02+00:00Added an answer on June 13, 2026 at 11:06 pm

    Make sure your form is multipart:

    enctype="multipart/form-data"
    

    Forgetting this is a common cause of your error.

    EDIT: File uploads are not possible through ajax*. There are a few options:

    1. Post the form
    2. Post the form in an iframe if you don’t want the page to refresh
    3. *Not strictly true. You can use the FormData object (not supported in older browsers)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many question regarding this topic but there is no clear answer. Although
I couldn't find a duplicate for this question for Java, although there are a
Is there a leak in this C code? Although the answer is coming correct,
Although there are many solutions provided even here at stackoverflow, none of them seems
Although there are some similar questions I’m having difficulties finding an answer on how
Although there are a lot of jquery autocomplete code in this forum. However I
I am currently trying to create a content uploading system and although there are
Although the question title appears a bit subjective I am sure there is not
I know there are a lot of questions targeting this issue. Although there are
First things first, there are many questions similar to this, I know, but I

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.