Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageUploader部分安卓机,选择相册后不能上传 #6274

Open
Callie123 opened this issue Jul 31, 2023 · 6 comments
Open

ImageUploader部分安卓机,选择相册后不能上传 #6274

Callie123 opened this issue Jul 31, 2023 · 6 comments
Labels

Comments

@Callie123
Copy link

Version of antd-mobile

5.20.0

Operating system and its version

Android

Browser and its version

微信H5

Sandbox to reproduce

No response

What happened?

在不点击相册筛选的情况下可以上传图片,如果点击相册筛选图片就不能上传。目前仅在安卓机型小米机型是上发现此问题

Relevant log output

const upload = async (file: any) => {
    let lrzFile: any = await new Promise(resolve => {
      lrz(file, { quality: file.size > 1024 * 1024 * 2 ? 0.5 : 1 }).then(
        (res: any) => {
          resolve(res.base64);
        },
      );
    });
    let formData = new FormData();
    formData.append('file', lrzFile);
    let res: any = await uploadImage({ image: lrzFile });
    return {
      url: res.data,
    };
  };

<Form.Item
          name="images"
          label="生活照"
          rules={[{ required: true, message: '请上传生活照' }]}
        >
          <ImageUploader
            multiple
            maxCount={10}
            imageFit={'contain'}
            showUpload={fileList.length < 10}
            onCountExceed={exceed => {
              Toast.show(`最多选择 ${10} 张图片,你多选了 ${exceed}`);
            }}
            upload={upload}
          />
        </Form.Item>
@Callie123 Callie123 added the bug label Jul 31, 2023
@miracles1919
Copy link
Contributor

不能上传是指什么? 是指 upload 回调没有触发吗?

如果是 upload 回调没有触发,可以尝试用原生 input type='file' 试试能否触发回调,大概率是浏览器的问题

@renlimina
Copy link

最近做的一个项目也遇到这个问题了,但是不太确定是哪个机型,我没复现出来,也是相册里面选照片上传不了,版本用的是5.21.0

@qaz601588183
Copy link

我最近在红米的机型上也碰到这个问题,最近照片可以正确触发,但是相册里的照片却无法正确触发上传事件。

@yejinghun
Copy link

我也遇到了这个问题,手机是华为,点击上传的时候,不选相册照片能够上传成功,但是一进相册选择照片就上传不了,upload也没没收到上传事件

@xianxin011
Copy link

现在移动端对获取相册中的的照片有限制,需要配合原生开发获取移动设备获取手机相册的权限就可以拿到相册中的权限。这个问题最好的处理办法就是通过原生去获取图片,因为这个组件的本质是input type="file",IOS和安卓存在兼容问题

@wyysf123
Copy link

我遇到的是这样的,如果你上传一张照片在这个照片没上传完成之前,你再点击选择图片上传就不会触发上传了,很奇怪,很好复现的,前提是调用接口上传到服务器,如果自己模拟不会有问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants