亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Upload component selects a file and does not upload it immediately
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-05-19 10:13:15
0
4
769

antd's Upload component, I want to not upload the file immediately after selecting it, but upload it together after I press the save button. How to do this?

PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證高級(jí)PHP講師

reply all(4)
過去多啦不再A夢(mèng)
  • Use beforeUpload to store the things to be uploaded in the store (state can also be used), and finally return false to prevent uploading.


    <Dragger
        name="ver_file"
        action="version_add"
        showUploadList
        disabled={activeRow.id !== 0}
        fileList={fileList}
        onRemove={() => {
          // 清空文件列表
          dispatch({
            type: 'SystemSettings/Version/changeFileList',
            payload: {
              file: {},
              fileList: [],
            },
          });
        }}
        beforeUpload={(curFile, curFileList) => {
          // 將上傳的東西存到store里,返回false阻止上傳
          dispatch({
            type: 'SystemSettings/Version/changeFileList',
            payload: {
              file: curFile,
              fileList: curFileList,
            },
          });
          return false;
        }}
   >
  • When submitting, append file to FormData

    const data = new FormData();
    // 循環(huán)把字段全部加進(jìn)去
    Object.entries(values).forEach((item) => {
      data.append(item[0], item[1] || '');
    });
    data.append('ver_file', file);
    dispatch({
      type: 'SystemSettings/Version/submitData',
      payload: data,
    });
Peter_Zhu

After you select the file, base64 will be displayed. Just save it together when you click Save

Ty80

Has the question been solved?

小葫蘆

I have the same question, lz I want to share it. I also encountered a requirement that I don’t want to upload it immediately. How can I do it?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template