English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm uploading an image from my aspx page to a folder(not in database) in ftp server using the following code::

System.IO.FileStream newFile
= new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),System.IO.FileMode.Create,FileAccess.ReadWrite, FileShare.ReadWrite);
newFile.Write(myData, 0, myData.Length);

I'm using a fileupload control to select an image.
now, when i'm running this page from my local server, and click the save button...the selected image is being stored in the webserver.

but, when i hosted this page, run from the web server, select an image and click the save button, a popup window asking for ftp username and pasword is appearing.
Now, what my question is, how to pass the login credentials to the ftp server through my code.
thanks in advance...

2007-07-31 20:08:29 · 1 answers · asked by quest_.net 1 in Computers & Internet Programming & Design

Please note that i dont want to use this kind of code::

string ftpurl = "ftp:////";
HttpPostedFile myFile = fileupload.PostedFile;
string sFilename = System.IO.Path.GetFileName(myFile.FileName);

string fname = ftpurl + sFilename;
WebClient mywebclient = new WebClient();

mywebclient.Credentials = new NetworkCredential("username", "password");
mywebclient.UploadFile(fname.ToString(),myFile.FileName.ToString());


(and i dont want to use any third party components)
Could anyone please help me and tell me how to pass the ftp login credentials through my code.
thanks in advance..

2007-07-31 20:09:25 · update #1

1 answers

It sounds like you are redirecting the page to the FTP site. I've done quite a bit of development with FTP sites and I don't think that's possible without making the user type in credentials, unless the FTP site is anonymous.

You could setup the FTP with anonymous access, and only allow browse and read-only access.
The title of your question is about "image uploading" if that's your problem, then it sounds like the user really doesn't need to see the FTP directly. You would upload the file like you are doing and then if you need to put it on an FTP site, you can use the FTP object supplied within C# (or VB) to do the uploading on the backend.

2007-07-31 20:32:24 · answer #1 · answered by Michael M 6 · 0 0

fedest.com, questions and answers