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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:53:57+00:00 2026-05-12T12:53:57+00:00

I have a field of type image in my database which is mapped as

  • 0

I have a field of type image in my database which is mapped as binary in my model (ADO.NET Entity Framework).

But somehow the image that I get from the input file box is not being passed to the object. I know this because I debuged my action and the object Language (the image I trying to upload to the database is a flag) has the property Flag set to null and that is very bad! It should contain the image uploaded. Do I have to do something else?

Below is my form html code and my action code:

<% using (Html.BeginForm("Create", "Language", FormMethod.Post, 
          new {enctype="multipart/form-data"})) {%>
    <fieldset>
        <legend>Fields</legend>
        <p>
            <label for="Id">Id:</label>
            <%= Html.TextBox("Id") %>
            <%= Html.ValidationMessage("Id", "*") %>
        </p>
        <p>
            <label for="Name">Name:</label>
            <%= Html.TextBox("Name") %>
            <%= Html.ValidationMessage("Name", "*") %>
        </p>
        <p>
            <label for="Flag">Flag:</label>
            <!--
            File box is a helper that I got from this link:
            http://pupeno.com/blog/file-input-type-for-forms-in-for-asp-net-mvc/
            -->
            <%= Html.FileBox("Flag")  %>
            <%= Html.ValidationMessage("Flag", "*") %>
        </p>
        <p>
            <label for="IsDefault">IsDefault:</label>
            <%= Html.TextBox("IsDefault") %>
            <%= Html.ValidationMessage("IsDefault", "*") %>
        </p>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>

<% } %>

I am using Visual Studio 2008.

[AcceptVerbs(HttpVerbs.Post)]  
public ActionResult Create(Language language)  
{  
    // Here language.Flag is null. Shouldn't the Flag property be a
    // binary field ready to be stored in the database along with the others?
    if (!ModelState.IsValid || !_service.CreateLanguage(language))  
    {  
        return View("Create", language);  
    }  
    return RedirectToAction("Index");  
}  

What am I doing wrong?

  • 1 1 Answer
  • 1 View
  • 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-05-12T12:54:00+00:00Added an answer on May 12, 2026 at 12:54 pm

    Thank you for your responses, but fortunately I found a better way.

    I changed the action method signature:
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(Language language)

    to:
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(HttpPostedFileBase Flag, Language language)

    Then I attribute the Flag filename to language.Flag and keep only the reference to where the file is (This is because we decided to keep the database as small as possible, but I am sure this new signature would work as well to convert the file to database).

    Hope this helps other people too!

    Sorry I can’t give you a thumbs up. Not enough reputation…

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

Sidebar

Related Questions

I have little doubt, I have a field of type oid in my database
I have a field aliases of type java.util.Set in one Entity . This Set
All rows in a table have a type field which is either 0 or
I have a field type varchar in sql server. It contains data like 010109
I have this Points table: =========================================== FIELD : TYPE =========================================== id int(11) user_id int(11)
I have a Lucene index that contains documents that have a type field, this
Ok I'm using SQL Server 2008 and have a table field of type VARCHAR(MAX)
I have a boolean (BOOL) type field in the SQLite table. In the SubSonic
I have a design model, which allows designers to upload a design they have
i have an image filed in my model and i want to write SQL

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.