ExtJS文件上传表单方法

ExtJS file upload form method

本文关键字:表单 方法 文件 ExtJS      更新时间:2023-12-02

如何使用PUT方法的文件上传表单而不是POST?这是我的表单代码:

this.personEditForm = new Ext.FormPanel({
  xtype:"form",
  fileUpload:true,
  frame:true,
  autoScroll:true,
  layout:{
    type:"vbox",
    flex:"even"
  },
  items:[
    {
      xtype:'fileuploadfield',
      emptyText:'Выберите файл...',
      name:'avatar',
      width:300,
      fieldLabel:'Фото пользователя',
      buttonText:'Обзор'
    }
  buttons:[
    {
      text:'Сохранить',
      handler:function () {
        if (self.personEditForm.getForm().isValid()) {
          method = "PUT";
          url = PERSONS_URL + personID;
          self.personEditForm.getForm().submit({
            method:method,
            url:url,
            success:function (form, action) {}
          });
        }
      }
    }
  ]
 });

当我删除文件字段时,PUT方法成功了。怎么了?

文档仅使用GET或POST方法进行指定。http://docs.sencha.com/ext-js/4-1/#/api/Ext.form.Basic-cfg-method