我發展模式當GWT如何mkdirs。 fileupload工作得很好。但我會做目錄在Linux上/var/wms/year/month/file.jpg。從客戶端這是我的源代碼: 附加組件形成客戶端文件上傳在Eclipse
fileUpload = new SingleUploader(FileInputType.LABEL);
fileUpload.setFileInputPrefix("PJ");
fileUpload.addOnFinishUploadHandler(onFinishUploaderHandler);
layoutContainerItemRight.add(fileUpload, formData);
方法是addOnFinishUploadHandler
private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
if (uploader.getStatus() == gwtupload.client.IUploadStatus.Status.SUBMITING) {
String month = VisionProperties.getBulan();
String year = DateTimeFormat.getFormat("d-M-yyyy").format(new Date()).split("-")[2];
String strDirectoy = "/var/wms/" + year + "/" + month + "/";
File file = new File(strDirectoy);
if (!file.exists()) {
file.mkdirs();
}
}
if (uploader.getStatus() == gwtupload.client.IUploadStatus.Status.SUCCESS) {
String msg = uploader.getServerInfo().message;
fileName = msg.toString();
if(selectWindow != 2){
img.setUrl("servlet.gupld?show=&fieldname=" + fileName);
itemPanel.render(img.getElement());
}else{
tb.setVisible(true);
tb.setText("Download File "+uploader.getFileName());
}
}
}
};
如何使當上傳文件的過程目錄下的文件?
GWT打包機:http://www.vectomatic.org/google-web-toolkit/a-file-api-for-gwt – Spiff 2013-04-24 06:49:58