Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.9k views
in .NET FTP by
Hi, great product by the way.

I have a site where users upload their files through an input file textbox. when i try to ftp the file to another server, i get a security error message saying "access to the file is denied." when I however upload the file to hte server and then ftp it from there, it works fine. Do you know of a way arond this? thanks

code


'Instanciate a new instance of an FTP client
Dim objFTP As New EnterpriseDT.Net.Ftp.FTPClient

Dim flePosted As System.Web.HttpPostedFile

'Store Posted file in variable defined above
flePosted = fleTest.PostedFile

'Specify the connection mode for the ftp client (Passive)
objFTP.ConnectMode = Net.Ftp.FTPConnectMode.PASV

'Time out for FTP connection (in seconds I believe)
objFTP.Timeout = 700

'Host for FTP
objFTP.RemoteHost = "*******"

'Get file path
Dim flePath As String = System.IO.Path.GetFullPath(flePosted.FileName)


Try
'
objFTP.Connect()
objFTP.User("*****")
objFTP.Password("******")
objFTP.TransferType = Net.Ftp.FTPTransferType.BINARY
objFTP.Put(flePath, "testing")
objFTP.Quit()
Response.Write("Connected to host")
'
Catch ex As Exception

Try
objFTP.Quit()
Catch exm As Exception
Exit Try
End Try

Response.Write("Could not connect to host, server error: <br /><font color='red'>" & ex.Message & "</font>")
End Try

3 Answers

0 votes
by (162k points)
When you say you are trying to FTP the file from the server (which I presume is the server that users upload to) to another server, how are you doing this?

Hi, great product by the way.

I have a site where users upload their files through an input file textbox. when i try to ftp the file to another server, i get a security error message saying "access to the file is denied." when I however upload the file to hte server and then ftp it from there, it works fine. Do you know of a way arond this? thanks
0 votes
by
hi

I was hoping that i could specify the path of the file on the users computer and then FTP to another server withou having to store it on the server which the script is running from.

eg

Dim flePosted as system.web.httpPostedFile
strFilePath as string = system.web.IO.getFilePath(flePosted)

from the above, i have the path of the file on the users computer, and I tried to ftp it to another server by

objFTP.Put(strFilePath, renamedfile.txt)

I get an "access to the file ...." is denied error with this, i guess it's a security feature really or else "rogue" users would just FTP all files on clients machine.

Right now, the way I have done it, is i upload the file unto the current server and then ftp if from the current server to another, afterwards deleting the file. is there a better way to do it?
0 votes
by (560 points)
hi
Right now, the way I have done it, is i upload the file unto the current server and then ftp if from the current server to another, afterwards deleting the file. is there a better way to do it?


You could use an in-memory stream, instead of a temporary file. I am designing v2 of my clients system to do just this.

Now - if you are using a memory stream, instead of a temp file because the contents are "sensitive" - remember, there are no guarantee's that in-memory streams might not be saved to the system page file if Windows needs to page some memory...

Categories

...