我有一个java代码可以在本地驱动器上传图像。现在我想当用户上传图片时我们应该在远程位置上传它我怎样才能实现...
try {
String UPLOAD_DIRECTORY = "E:\\uploaded";
File uploadsFolder = new File(UPLOAD_DIRECTORY);
String fileName = item.getName();
if (fileName != null) {
fileName = FilenameUtils. getName(fileName); // uploaded file filename
}
File uploadedFile = new File(uploadsFolder, fileName);
item.write(uploadedFile);
/// Save a list with the received files
receivedFiles.put(item.getFieldName(), uploadedFile);
receivedContentTypes.put(item.getFieldName(), item.getContentType());
/// Send a customized message to the client.
response += uploadedFile;
} catch (Exception e) {
throw new UploadActionException(e);
}
答案 0 :(得分:1)
这是服务器端,它与GWT无关。您必须通过http客户端进行多形式发布。