FTP upload for aspx page

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Here i'm using this code to upload a local file to my ftp server on te web
It's work fine on my PC but when i publish. I have an error "cannot find
local file"

Here's the code :
'Get FTP web resquest object.
ftpWR = CType(FtpWebRequest.Create(New Uri("ftp://" +
System.Configuration.ConfigurationManager.AppSettings("ftpServer").ToString()
+ "/" + uploadFile.FileName)), FtpWebRequest)

ftpWR.UseBinary = True
ftpWR.Method = WebRequestMethods.Ftp.UploadFile
ftpWR.Credentials = New
NetworkCredential(System.Configuration.ConfigurationManager.AppSettings("ftpUserName").ToString(),
System.Configuration.ConfigurationManager.AppSettings("ftpPassword").ToString())

'Get physical file



Dim fi As FileInfo = New
FileInfo(UploadFile.PostedFile.FileName)
Dim contents As Byte() = New Byte(fi.Length) {}


'Read file
Dim fs As FileStream = fi.OpenRead()
fs.Read(contents, 0, fi.Length)
fs.Close()

'Write file contents to FTP server
Dim rs As Stream = ftpWR.GetRequestStream()
rs.Write(contents, 0, fi.Length)
rs.Close()

ftpWP = ftpWR.GetResponse()

Need help!
 
You web application runs on your web server. Thus "local" means the web
server machine. Your user is using a browser session on his client machine.
You likely need a special control to upload FTP from a web page.
 
Back
Top