FTP upload for aspx page

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!
 
E

Eliyahu Goldin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top