2 Replies - 7158 Views - Last Post: 12 November 2011 - 12:20 AM

#1 Morgester  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-October 11

How would I upload a file from server A to server B?

Posted 22 October 2011 - 08:30 AM

Hello Forum.

I am working on a site and I need to store uploads on a different server/domain. Server A is http://example.com and Server B is http://example.com. My ASP.NET application is running on Server A and I want it to store the uploads that I do on it to Server B.

I am having difficulties knowing what to do really.

Any help would be appreciated, I am using C#.

Thanks,

Morgester.

Is This A Good Question/Topic? 0
  • +

Replies To: How would I upload a file from server A to server B?

#2 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: How would I upload a file from server A to server B?

Posted 24 October 2011 - 02:47 PM

Have you considered implementing a Web Service that would store the images for you.
You could host this Web Service on Server B and call it from your ASP.NET application which is hosted on Server A.

-Frinny
Was This Post Helpful? 0
  • +
  • -

#3 Mr.Bright  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 05-November 11

Re: How would I upload a file from server A to server B?

Posted 12 November 2011 - 12:20 AM

server B you can build a FTP server.
then on server A you can upload to B
here is the method that upload the file to ftp server.
use
public void Upload(string filename,string ftpServerIP ) 

        {

            FileInfo fileInf = new FileInfo(filename);

            string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;

            Connect(uri);       

            reqFTP.KeepAlive = false;

            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

            reqFTP.ContentLength = fileInf.Length;

            int buffLength = 2048;

            byte[] buff = new byte[buffLength];

            int contentLen;

            FileStream fs = fileInf.OpenRead();

            try

            {

                Stream strm = reqFTP.GetRequestStream();

                contentLen = fs.Read(buff, 0, buffLength);

                while (contentLen != 0)

                {


                    strm.Write(buff, 0, contentLen);

                    contentLen = fs.Read(buff, 0, buffLength);

                }

                strm.Close();

                fs.Close();

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message, "Upload Error");

            }

        }

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1