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.
2 Replies - 5314 Views - Last Post: 12 November 2011 - 12:20 AM
#1
How would I upload a file from server A to server B?
Posted 22 October 2011 - 08:30 AM
Replies To: How would I upload a file from server A to server B?
#2
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
You could host this Web Service on Server B and call it from your ASP.NET application which is hosted on Server A.
-Frinny
#3
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
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");
}
}
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|