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

  • Home
  • SEARCH
  • 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 3336234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:06:40+00:00 2026-05-18T00:06:40+00:00

Currently, I am uploading PDF files, and images from my MVC web application to

  • 0

Currently, I am uploading PDF files, and images from my MVC web application to a sql server database. This works perfectly, however I now want to be able to upload ePub files.

I tried to do it with the same uploader in some vain hope that it would work, however this is the error I get:

SqlException was unhandled by the user
code.

“The parameterized query
‘(@FileContent varbinary(max)
,@MimeType nvarchar(4000),@FileName’
expects the parameter ‘@MimeType’,
which was not supplied.

Here is also the code from my controller which handles the uploads:

public ActionResult Index()
{

    foreach (string upload in Request.Files)
    {
        if (!Request.Files[upload].HasFile1()) continue;

        string mimeType = Request.Files[upload].ContentType;
        Stream fileStream = Request.Files[upload].InputStream;
        string fileName = Path.GetFileName(Request.Files[upload].FileName);
        int fileLength = Request.Files[upload].ContentLength;
        byte[] fileData = new byte[fileLength];
        fileStream.Read(fileData, 0, fileLength);

        const string connect = @"Server=localhost;Database=Images;user id=taraw; password=****;";
        using (var conn = new SqlConnection(connect))
        {
            var qry = "INSERT INTO FileStore (FileContent, MimeType, FileName) VALUES (@FileContent, @MimeType, @FileName)";
            var cmd = new SqlCommand(qry, conn);
            cmd.Parameters.AddWithValue("@FileContent", fileData);
            cmd.Parameters.AddWithValue("@MimeType", mimeType);
            cmd.Parameters.AddWithValue("@FileName", fileName);
            conn.Open();
            cmd.ExecuteNonQuery();
        }
    }

    return View();
}

I know the error is pretty self explanatory as to what the problem is, I’m just unsure how to modify the code to allow it to accept ePub File formats.

Any help would be greatly appreciated 🙂

  • 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-18T00:06:41+00:00Added an answer on May 18, 2026 at 12:06 am

    Found out that the mimetype for an epub file is application / epub + zip. Specified this in my application rather than expecting it from the user and this seems to have done the trick. File is uploading and downloading without any issues.

    Thanks to anyone who commented 🙂

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

Sidebar

Related Questions

I am currently uploading images to my server via HTTP POST. Everything works fine
Im currently uploading data to MS SQL server via SQLBulkCopy and Transactions. I would
The upload script in this page is currently uploading the images to the same
I am currently uploading images pasted from the clipboard with the following code: //
I'm currently developing a web application whose primary user function is uploading and downloading
Currently my form is showing 3 'input' fields for uploading 3 files. This looks
I am currently looking in to some file uploading using Java Server Faces. I've
Here is my scenario: I am currently upgrading a web site I maintain from
I am currently uploading files in ActionScript 3 using the upload() method of the
I'm deploying my application to Tomcat, which currently involves uploading a ~40MB war file

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.