简体   繁体   English

EXTJS如何在json对象中从extjs客户端将图像上传到hsql数据库

[英]EXTJS How to upload image to hsql database from extjs client side in json object

I have image upload field like 我有像这样的图片上传字段

{
    xtype: 'textfield',  
    fieldLabel: 'Image',  
    labelSeparator: '',  
    name: 'newPic',  
    id:'newPic',  
    anchor:'100%',  
    inputType: 'file',  
    allowBlank: false  
}

When i submitting form, Im encoding all form data in a json object.All textfields data are coming in json object but not image is passing to server side . 当我提交表单时,我将所有表单数据编码在一个json对象中。所有文本字段数据都在json对象中传入,但没有图像传递到服务器端。 How to pass image so as to save it in server side 如何传递图像以将其保存在服务器端

var form=Ext.getCmp('empPersonal');
var formdata=Ext.JSON.encode(form.getValues());
alert(""+formdata);
if(Ext.getCmp('empPersonal').getForm().isValid()) {
    Ext.Ajax.request({ 
    url:'ws/employees/create/'+formdata,

You should use Ext.form.field.File and not just textfield . 您应该使用Ext.form.field.File而不是textfield This control will let user browse for a file on local machine and this file will be included in the POST message sent to the server: 该控件将允许用户浏览本地计算机上的文件,并且该文件将包含在发送到服务器的POST消息中:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.File http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.File

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM