Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.9k views
in .NET FTP by (280 points)
I'm trying to create an browser based ftp client to upload images to a Ftp server but I'm not able to upload any images which are residing in Local Setting folders such as desktop or MyDocuments. If I pick file to upload from any other location it uploads file without any problem but if file is picked from MyDocuments or Desktop I get Access Denied error and on tracking deep I found its through "FileNotFoundException" although file exist in that location.

I'm not able to find out a possible solution to this problem. Please suggest me what is going wrong in this. I'm using FtpConnection class file for upload functions with edtFtpNet


Public Function FTPUploadImage() As String

Dim FTPConn As New FTPConnection

Dim strImageUpload As String

Try

FTPConn.ConnectMode = Me.ConnectMode

FTPConn.ServerAddress = Me.FTPServer

FTPConn.UserName = Me.FTPLoginName

FTPConn.Password = Me.FTPPassword

FTPConn.Connect()

FTPConn.Login()

If FTPWorkingDir <> "" Then

FTPConn.ChangeWorkingDirectory(FTPWorkingDir)

End If

strImageUpload = GetImageName(Me.ImagePath)

FTPConn.UploadFile(Me.ImagePath, strImageUpload)   ' This is the line when upload fails if I'm uploading a file from MyDocuments or Desktop

Catch ex As Exception

Throw ex

End Try

Return strImageUpload

End Function

8 Answers

0 votes
by (162k points)
If you can enable EDT's logging and post the relevant section of the logfile (and a stack trace) we'll take a look.
0 votes
by (280 points)
If you can enable EDT's logging and post the relevant section of the logfile (and a stack trace) we'll take a look.


Thanks for your reply. Can you explain how i can enable EDT's logging and see logfile for the details. I'm using edtFtpnet.dll in a web project.
0 votes
by (280 points)
If you can enable EDT's logging and post the relevant section of the logfile (and a stack trace) we'll take a look.


This is all I was able to find out from stack trace

Message   "Access to the path "C:\Documents and Settings\AkhileshSharma\My Documents\My Pictures\800px-Amazon_57.53278W_2.71207S.jpg" is denied."
Source   "mscorlib"
StackTrace   "   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at EnterpriseDT.Net.Ftp.FTPClient.PutBinary(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile)
   at FtpClientUtilityVB.FTPClient.FTPUploadImage() in C:\Inetpub\wwwroot\FtpClientUtilityVB\BusinessObjects\FTPClient.vb:line 151"



Other thing I traced from exception was that It was giving FileNotFoundException although file exist at the location specified in MyDocuments
0 votes
by (162k points)
This looks like a permissions problem. i.e. you don't have permission to read that file.

Where is this code actually running? Is it an ASP?
0 votes
by (280 points)
This looks like a permissions problem. i.e. you don't have permission to read that file.

Where is this code actually running? Is it an ASP?


Yes its an ASP.Net Application using vb.net. This application will allow users to upload image to specified FTP server from a web application running on Internet. Problem is on the client machine not of the server as if a user uploads an image from any other location then mydocuments or desktop he can upload but if image is being picked from mydocuments or desktop it gives error and image is never uploaded.

Also not able to check size of image being uploaded from mydocuments and desktop but i can do that if image is picked from any other location.
0 votes
by (162k points)
1. If your ASP.NET application is hosted on a webserver which is on a different machine, it isn't going to find files that you select on your local machine.

2. If the webserver is on the same machine and you know the files are there, ASP.NET probably doesn't have permission to read My Documents from within IIS anyway.
0 votes
by (280 points)
1. If your ASP.NET application is hosted on a webserver which is on a different machine, it isn't going to find files that you select on your local machine.

2. If the webserver is on the same machine and you know the files are there, ASP.NET probably doesn't have permission to read My Documents from within IIS anyway.


I think its the case 1.

I have application hosted on a webserver and I'm accessing it using internet and http protocol something like http://www.mydomain.com/UploadFile.aspx which uploads files to my websever in a specified directory.

But when I try to upload files from my machine to server using this application which uses edtFtpnet I get different errors such as:
1. at times it returns a message "Cound not find file <path><filename>"
2. at times it returns a message "Unable to read data from the transport connection"
3. at some of the times it displays only the "<path><filename>"

I'm not sure where its going wrong.

and as you said in case 1. that if application is running on a webserver on a different machine and I'm trying to access application from a client machine to upload file and picking file from my client machine it would not find files on my machine then what is the purpose of upload functionality using ftp?

People do Ftp to upload files on a remote machine from their local machine and that is what I'm doing and I'm not sure if edtFtpNet support it properly.

Can anybody through a vb.net code for using in asp.net for file upload using edtftpnet, so that I can compare what I'm not doing properly. It would be a great help. I want to thanks to all who help in for this.
0 votes
by (162k points)
You can't do it like you are suggesting. If the FTP client is not running on your machine (it is running on the ASP.NET server) there is no possible way it can upload files from your machine.

Take a look at HTTP file upload for what you are suggesting.

and as you said in case 1. that if application is running on a webserver on a different machine and I'm trying to access application from a client machine to upload file and picking file from my client machine it would not find files on my machine then what is the purpose of upload functionality using ftp?

People do Ftp to upload files on a remote machine from their local machine and that is what I'm doing and I'm not sure if edtFtpNet support it properly.

Categories

...