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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:04:53+00:00 2026-05-23T00:04:53+00:00

I am trying to update the text and images which is already updated to

  • 0

I am trying to update the text and images which is already updated to the databases. I have got a admin section in which there is a news menu, where the user can edit and update the news with images. The problem is i can edit and update the news text but the images doesnt update . Below is the controller and view :

 [HttpPost]
    [ValidateInput(false)]
    public ActionResult Edit(int id, FormCollection collection, IEnumerable<HttpPostedFileBase> files)
    {
        INewsRepository newsResp = new NewsRepository();
        News news = newsResp.GetNews(id);

        if (TryUpdateModel(news)){
            newsResp.Save();
            return RedirectToAction("Index");
        }else{
            return View();
        }
    }
<% using (Html.BeginForm("Edit", "News", FormMethod.Post, new { enctype = "multipart/form-data" }))
                  { %>

                <%: Html.ValidationSummary(true) %>
                <table cellpadding="2" cellspacing="2" border="0">
                    <tr>
                        <td style="width:100px;">
                            <div class="editor-label">
                                Title</div>
                        </td>
                        <td>
                            <div class="editor-field">
                                <%: Html.TextBoxFor(model => model.Title, new { style = "width:300px;" })%>
                                <%: Html.ValidationMessageFor(model => model.Title)%>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div class="editor-label">
                                Article content</div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div class="editor-field">
                                <%: Html.TextAreaFor(model => model.Article, new { @class = "tinymce" })%>
                                <%: Html.ValidationMessageFor(model => model.Article)%>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Image 1
                        </td>
                        <td>

                            <img height="56px" width="75px" alt="image1" src="/content/images/content/<%: Model.ImageLarge %>" />
                            <br />

                            <input type="file" name="files" id="file1" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Image 2
                        </td>
                        <td>

                            <img height="56px" width="75px" alt="image1" src="/content/images/content/<%: Model.ImageLarge2 %>" />
                            <br />

                            <input type="file" name="files" id="file2" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Image 3
                        </td>
                        <td>
                            <img height="56px" width="75px" alt="image1" src="/content/images/content/<%: Model.ImageLarge3 %>" />
                            <br />

                            <input type="file" name="files" id="file3" />
                        </td>
                    </tr>
                </table>

                <p>
                    <input type="submit" value="Save" />
                </p>
                <% } %>
  • 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-05-23T00:04:54+00:00Added an answer on May 23, 2026 at 12:04 am

    TryUpdateModel won’t update files. You could manually copy the streams into the corresponding property of your News model:

    foreach (var file in files)
    {
        byte[] buffer = new byte[file.InputStream.Length];
        file.InputStream.Read(buffer, 0, buffer.Length);
        news.Files.Add(buffer);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying update text views while this loop is processing. Here is my
I'm trying to update my text area via ActionScript code using this: scoreLabel.text =
I am trying to UPDATE a mysql TEXT data-type column with a string contains
I'm making a 'post text' app and trying to update my database with name
I am trying to make a bar chart using tables, which I have almost
I have a CodeIgniter web app I'm trying to convert (UPDATE: I'm trying to
I am trying to achieve a table which has text rotated -90degrees. Up until
i'm trying to change the Text on the BUTTON dynamically which is in the
I have a java desktop application for which I am trying to create a
I've got a simple carousel implementation which I'm trying to tweak a bit to

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.