forum member私はextjs 4とJAVAのファイルアップロードにいくつか問題があります。私はextjs4とアップロードフォームのコードを使用していますextjsで画像ファイルをアップロードする4 spring
は、ボタンのアップロード画像は作用を有する
{
xtype: 'filefield',
margin: '10 0 0 5',
width: 296,
fieldLabel: 'Image',
emptyText: 'Select Company logo...',
id: 'cmplogo',
itemId: 'cmplogo',
name: 'cmplogo',
labelWidth: 70
},
{
xtype: 'button',
margin: '10 0 0 90',
width: 89,
text: 'Upload Image',
action: 'btn-upload-img'
},
です:
fileUpload: function(btn) {
var win = btn.up('window');
var form = win.down('form').getForm();
alert('VALUE IS :'+form.getValues());
if(form.isValid()){
form.submit({
url : 'company/UploadFile.action',
waitMsg: 'Uploading your file...',
success: function(fp, o) {
Ext.Msg.alert('Success', 'Your file has been uploaded.');
}
});
}
},
と下に定義された機能を備えた 'BTN-アップロード-IMG' を私のJavaコントローラは以下の機能コードを持っています
@RequestMapping(value = "/company/UploadFile.action")
public @ResponseBody
Map<String, ? extends Object> uploadFile(UploadItem uploadItem, BindingResult result) throws Exception {
System.out.println("QUERY TO UPLOAD FILE");
try {
if(result.hasErrors()) {
for(ObjectError error: result.getAllErrors()) {
System.err.println("Error: "+error.getCode()+" - "+error.getDefaultMessage());
}
}
else
{
MultipartFile file = uploadItem.getFileData();
String fileName = null;
InputStream inputStream = null;
OutputStream outputStream = null;
if(file.getSize() > 0) {
inputStream = file.getInputStream();
if(file.getSize() > 10000) {
System.out.println("FILE SIZE:::"+file.getSize());
}
System.out.println("SIZE ::"+file.getSize());
fileName = "E:\\images\\"+file.getOriginalFilename();
outputStream = new FileOutputStream(fileName);
System.out.println("FILE NAME AND PATH IS ::"+fileName);
System.out.println("FILENNAME ::"+file.getOriginalFilename());
int readBytes = 0;
byte[] buffer = new byte[10000];
while((readBytes = inputStream.read(buffer, 0, 10000)) !=-1) {
outputStream.write(buffer, 0, readBytes);
}
outputStream.close();
inputStream.close();
}
}
} catch (Exception e) {
return getModelMapError("Error trying to read city");
}
return null;
}
上記の私のコードで何が間違っているかを知ってください。 私の放火魔コンソールがエラー
**uncaught exception: You're trying to decode an invalid JSON String: <pre>{"message":"Error trying to read city","success":false}</pre>**
の下に私を与えてくれ、私は私のエラーはすぐに解決し得ることを試みることができるいくつかのソリューションを提案してください。
は、あなたがあなたのケースで解決策を見つけ出すことができましたか? – pacman