File Upolad
-
Hi, I need to upload file in a folder at FTP server,i have already posted this but i need a coding guide not a software for this. The code i used is, txtfilurl.Text = FileUpload1.PostedFile.FileName; FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text); request.KeepAlive = false; request.UseBinary = true; Stream ftpstream = request.GetRequestStream();//--->This line shows the error FileStream file = File.OpenRead(txtfilurl.Text); int len = 1024; byte[] buff = new byte[len]; int bytesread = 0; do { bytesread = file.Read(buff, 0, len); ftpstream.Write(buff, 0, bytesread); } while (bytesread != 0); file.Close(); ftpstream.Close(); Error msg is:Web exception The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
-
Hi, I need to upload file in a folder at FTP server,i have already posted this but i need a coding guide not a software for this. The code i used is, txtfilurl.Text = FileUpload1.PostedFile.FileName; FileInfo filename = new FileInfo(txtfilurl.Text); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(txtaddr.Text + "/" + filename.Name); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(txtuser.Text, txtpass.Text); request.KeepAlive = false; request.UseBinary = true; Stream ftpstream = request.GetRequestStream();//--->This line shows the error FileStream file = File.OpenRead(txtfilurl.Text); int len = 1024; byte[] buff = new byte[len]; int bytesread = 0; do { bytesread = file.Read(buff, 0, len); ftpstream.Write(buff, 0, bytesread); } while (bytesread != 0); file.Close(); ftpstream.Close(); Error msg is:Web exception The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
Judging by the error, you gave an invalid path to the file on the FTP server. It's impossible to tell just by looking at the code.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Judging by the error, you gave an invalid path to the file on the FTP server. It's impossible to tell just by looking at the code.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hi, Thanx for replying,i am sure that i have given the right path i have checked many times. Is there is any other way to do the upload.
In that case, I'd use something like
EtheReal
to watch the TCP traffic coming out of your machine and see what the FtpWebRequest is actually sending to the FTP server.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008