0

My Tomcat is "7.0.59" and I want to upload file to server.

path as below:

tomcat7.0/[server folder]/upload

When I used localhost, file can upload to destination successfully.

But when I used other computer as client, it can't work!

(Server can get file name and other information correctly.)

Do I need to change the config or other setting?

Thanks!

1 Answer 1

1
use multipart form in jsp 
and server side use following code.

for(FileItem item : multiparts){
    if(!item.isFormField()){
        String name = new File(item.getName()).getName();
        item.write( new File(UPLOAD_DIRECTORY + File.separator + name));
        request.setAttribute("photoname", name);
    }else{
        // here get value of other parameter which is not file type
        System.out.println(item.getFieldName()+" = "+item.getString());
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.