Reputation: 102
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!
Upvotes: 0
Views: 125
Reputation: 2503
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());
}
}
Upvotes: 1