Discuss the FTP protocol, secure FTP, FTP over SSH and FTP over SSL.

Access Denied

no avatar
User

satyambdvp

Posts

7

Joined

Fri Jan 23, 2009 9:01 pm

Access Denied

by satyambdvp » Fri Jan 23, 2009 9:18 pm

:oops: Hi,


I am getting the following error when i am uploading a file to ftp.


Setting remote host
Connecting to server ftp.sajix.com
Connected and logged in to server ftp.sajix.com
com.enterprisedt.net.ftp.FTPException: /sajix/temp: Access is denied.


My code is as follows

try {
// create client
System.out.println("the Value of the Connection");
ftp = new FileTransferClient();

// set remote host
System.out.println("Setting remote host");
ftp.setRemoteHost(host);
ftp.setUserName(username);
ftp.setPassword(password);

// connect to the server
System.out.println("Connecting to server " + host);
ftp.connect();
System.out.println("Connected and logged in to server " + host);
ftp.setContentType(FTPTransferType.ASCII);
ftp.uploadFile(filename, "/sajix");
System.out.println("Finished Uploading File");
ftp.disconnect();
} catch (Exception e) {
System.out.println(e);
}

I am using Netbeans 6.5,J2EE 5.0,Tomcat 6.0.18

please help me out of this problem.

I tried SFTP , it worked fine.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Access Denied

by support2 » Fri Jan 23, 2009 10:17 pm

Try ftp.uploadFile(filename, "sajix");
no avatar
User

satyambdvp

Posts

7

Joined

Fri Jan 23, 2009 9:01 pm

by satyambdvp » Sat Jan 24, 2009 3:32 pm

Hi bruce,

I tried as you told but still it is showing Access Denied error if my code is like this

ftp.uploadFile(filename, "sajix");

if i upload to another folder in sajix,like this

ftp.uploadFile(filename, "sajix/temp");

then it is not showing any errors,but the file is not transfered into that folder.'temp' Folder is empty without any file.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Sat Jan 24, 2009 8:03 pm

You need to specify the actual filename, e.g.

ftp.uploadFile(filename, "/sajix/temp/myfile");

although with some servers it is better to change into the directory /sajix/temp and then use

ftp.uploadFile(filename, "myfile");
no avatar
User

satyambdvp

Posts

7

Joined

Fri Jan 23, 2009 9:01 pm

by satyambdvp » Tue Jan 27, 2009 1:35 pm

Hi Bruce,

Actually I want to upload "home.jsp" file to sajix->temp folder.My file is in Generated files->home.jsp.I am getting the real path as


ServletContext connect = servlet.getServletContext();
String filename = connect.getRealPath("/Generated files/home.jsp");


then I am uploading the file as follows


ftp.uploadFile(filename, "sajix/temp");

Here it is not showing any error but the file is not uploading.what is happening behind I don't know.

I tried as you told like this

ftp.uploadFile(filename, "/sajix/temp/home.jsp");


it is showing an error like

SEVERE: Invalid path was requested /NewFtpcheckAction


/NewFtpcheckAction is my action.
no avatar
User

satyambdvp

Posts

7

Joined

Fri Jan 23, 2009 9:01 pm

by satyambdvp » Tue Jan 27, 2009 2:05 pm

:D Hi Bruce,


Sorry for the before post as it is my fault.Actually I delete the action path from struts-config.xml and so it showed like that as

Invalid path requested error.


I tried as you told like this


ftp.uploadFile(filename, "/sajix/temp/home.jsp");


it worked fine.

Once again thanks bruce, for your quick reply and saved my lot of time wasted on other softwares.

Who is online

Users browsing this forum: No registered users and 0 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron