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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:11:37+00:00 2026-06-06T13:11:37+00:00

EDIT: Here’s a create script for the table minus the constraints on the keys

  • 0

EDIT:

Here’s a create script for the table minus the constraints on the keys for brevity.

CREATE TABLE [dbo].[ProfileFile](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ProfileID] [int] NOT NULL,
[FileTypeId] [int] NOT NULL,
[Data] [image] NOT NULL

EDIT:

Attempt to bypass NHibernate to access data in service layer

byte[] temp = (byte[])this._baseModelRepository.CurrentSession.CreateSQLQuery("SELECT Data FROM ProfileFile WHERE ProfileID = :ID").SetParameter("ID", id).UniqueResult();

EDIT:
After checking binary data saved in db, it seems that the entire file is uploaded and that my issue is actually on the side of displaying the image.

The image is not rendered but I can follow the action link to download the file but it is cut off at 8KB.

ProfileFile Model class Data field as generated by NHibernate

public virtual System.Byte[] Data { get; set; }

I hard coded the MIME type and file name for now while getting this set up.

public ActionResult GetProfilePhotoByID(int profileID)
    {
        var profileFile= //Load file object from DB by profileID
        byte[] byteArray = profileFile.Data;
        string mimeType = "image/jpg";
        string fileName = "ProfilePhoto.JPG";

        return File(byteArray, mimeType, fileName);
    }

Using debugger I found that the size of profileFile.Data is 8000. Maybe this is a NHibernate restriction?

Also, this is running with IIS and I am getting the same effect in Chrome, Firefox, and IE but am mainly testing in Chrome.

Original question:
I am trying to allow the user to upload a profile photo which I will then later serve up on their profile page. Unfortunately, the image file is not completely uploaded and is cut off at 8 KB. Below are simplified versions of some of the more important code segments.

Index View snippets

@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "profileform", enctype = "multipart/form-data" }))

<input type="file" id="photo" name="photo" />

Controller post action has HttpPostedFileBase photo parameter

byte[] input;
            if (photo != null && photo.ContentLength > 0)
            {
                input = new byte[photo.ContentLength];
                photo.InputStream.Read(input, 0, photo.ContentLength);


                if (model.ProfileFiles == null)
                {
                    model.ProfileFiles = new List<Core.Model.ProfileFiles>();
                }

                model.ProfileFiles.Add(new Core.Model.ProfileFiles()
                {
                    ProfileID = model.ID,
                    Profile = model,
                    Data = input
                });
            }

Model class is generated with NHibernate. The relevant field is

// One To Many:
public virtual IList<ProfileFile> ProfileFiles { get; set; }

Just comment if more information is needed.

  • 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-06T13:11:38+00:00Added an answer on June 6, 2026 at 1:11 pm

    Solved the issue, and with using NHibernate still too, using Peter Gluck’s answer to a related question.

    var persistenceModel = AutoMap.AssemblyOf<Model.BaseModel>()
        .Override<Model.ProfileFile>(map =>
        {
            // Sets max length of byte[] retrieved from image column of DB
            map.Map(x => x.Data).Length(2147483647);
        })
        ... etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When inserting values into my table what do I edit here? Do I delete
What tools are used to create installers like this: EDIT: Here's a full tutorial:
[EDIT: Here's a link to a mockup of what I'm trying to create] http://i53.tinypic.com/w9v2np.jpg
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
When a user links to link it redirects to edit.php - here's an example:
I'm looking to analyze and compare the following `signals': (Edit: better renderings here: oscillations
EDIT - The code looks strange here, so I suggest viewing the files directly
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: OK I asked the wrong question here. I'm going to be coding a

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.