Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
9.1k views
in General by (340 points)
: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.

5 Answers

0 votes
by (161k points)
Try ftp.uploadFile(filename, "sajix");
0 votes
by (340 points)
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.
0 votes
by (161k points)
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");
0 votes
by (340 points)
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.
0 votes
by (340 points)
: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.

Categories

...