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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:13:49+00:00 2026-06-11T05:13:49+00:00

I have been working at building a feature for a client that will enable

  • 0

I have been working at building a feature for a client that will enable them to upload images from http://www.site1.com, storing the image URL to the database and storing the images to a file on http://www.site2.com/images. I have managed to upload a file to the target location, but when I try to open and view the image, it is said to contain errors. I’ve never really had to work with images, so I’m at a loss.

This is the method used to upload the files:

public static void UpLoadImage(Stream image, string target)
    {
        FtpWebRequest req = (FtpWebRequest)WebRequest.Create("ftp://www.site2.com/images/" + target);
        req.UseBinary = true;
        req.Method = WebRequestMethods.Ftp.UploadFile;
        req.Credentials = new NetworkCredential("myUser", "myPass");
        StreamReader rdr = new StreamReader(image);
        byte[] fileData = Encoding.UTF8.GetBytes(rdr.ReadToEnd());

        rdr.Close();
        req.ContentLength = fileData.Length;
        Stream reqStream = req.GetRequestStream();
        reqStream.Write(fileData, 0, fileData.Length);
        reqStream.Close();
    }

This is where the method is called from (image1 is an HttpPostedFileBase):

myObject.UpLoadImage(image1.InputStream, storedTL.ID + "-1.png");

If there is a way that I can make this code work, or if there is an all around better way to do this, please help.

  • 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-11T05:13:50+00:00Added an answer on June 11, 2026 at 5:13 am

    StreamReader is meant to read text.

    Change:

    StreamReader rdr = new StreamReader(image);
    byte[] fileData = Encoding.UTF8.GetBytes(rdr.ReadToEnd());
    

    to

    byte[] fileData = File.ReadAllBytes(image);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on building my first CSS site using divs and am
I'm working on building a tree structure in MySQL and have been experimenting with
I’ve been working on a few small scale Access projects that have turned large
I am currently building an ecommerce site with PHP/MySQL. Recently, I have been working
I have been working on a C++ project that links to a .so(dynamic library)
been working on a site building software and have a bug thats driving me
First let me say that I have been working on this issue for about
I have been working on a project that requires downloading a zipped file off
I have developed a WCF service that has been working fine for a few
I have been building a Rails application that performs accounting functionality. As part of

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.