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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:29:24+00:00 2026-05-13T01:29:24+00:00

I have a FileUpload control. I am trying to save the file that is

  • 0

I have a FileUpload control. I am trying to save the file that is uploaded (an image) and also save several thumbnail copies of the file.

When I try something like this:

System.Drawing.Image imgOriginal = System.Drawing.Image.FromStream(PhotoUpload.PostedFile.InputStream);

I get an “System.ArgumentException: Parameter is not valid.”

I also tried using the PhotoUpload.FileBytes to create the image from the file bytes instead of the InputStream, but the same error occurs.

The uploaded file is a jpg. I know it’s a valid jpg since it saves the original ok.

Edit: This code actually does work. The Parameter is not valid was due to the PhotoUpload.PostedFile.InputStream being empty… which seems to be an entirely different issue. It looks like after I save the original the fileupload stream goes away.

Edit: Found out that the InputStream of a FileUpload can only be read/consumed one time and then it is gone.

To get around that I saved the fileupload filebytes into a byte array and used the byte array to create copies of the image.

Code:

// Copy the FileBytes into a byte array
byte[] imageData = PhotoUpload.FileBytes;

// Create a stream from the byte array if you want to save it somewhere:
System.IO.Stream myStream = new System.IO.MemoryStream(imageData);

// Or create an image from the stream as many times as needed:
System.Drawing.Image imgOriginal = System.Drawing.Image.FromStream(myStream);
  • 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-13T01:29:25+00:00Added an answer on May 13, 2026 at 1:29 am

    Have a look at this link

    ASP Net – How to pass a postedfile to a system.drawing.image

    Here’s my function call:

    uploadAndSizeImage(System.Drawing.Image.FromStream
    (uploadedFileMD.PostedFile.InputStream))

    I’m getting this error:

    Exception Details:
    System.ArgumentException: Invalid
    parameter used.

    Google isn’t turning up much though I
    did find a reference to it possibly
    being caused by the stream reader
    being at the end of the stream and me
    needing to reset it to position one.
    But that was kind of vague and not
    really sure if it applies here.

    Does this help?

    EDIT:

    Also, have you tried manually reading the file using something like

    System.IO.FileStream fs = System.IO.File.OpenRead(@"Image.JPG");
    byte[] data = new byte[fs.Length];
    fs.Read(data, 0, data.Length);
    
    System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
    System.Drawing.Image image = Image.FromStream(ms);
    

    Or saving a temp copy from the FileUpload and loading the image from file?

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

Sidebar

Related Questions

I have a .NET webform that has a file upload control that is tied
I have an ASP.NET web application that has a fileupload control to allow users
I'm running into an issue where I have a FileUpload control in an UpdatePanel.
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
I have a file upload form that is being posted back to a servlet
I have a form that excepts a file upload in ASP.NET. I need to
I have a web application that needs to take a file upload from the
I'm trying to use the FileUpload control in ASP.NET Here's my current namespace setup:
im trying to use a file upload control from the obout control library, i
I have a FileUpload control along with a required field validator. It throws an

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.