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
Upload: list-type为picture-card时,beforeUpload返回false后,文件仍然为上传中的状态 #8020
Comments
It will be better to write your issue/comment in English, so more people can understand you. |
参看文档:https://ant.design/components/upload-cn/#API 当 |
是停止上传了,但是图片还是显示“文件上传中”,这不是bug吗? |
beforeUpload: (file) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(e) {
// this is local preview
file.url = e.target.result;
this.setState(({ fileList }) => ({
fileList: [...fileList, file],
}));
}
return false;
} 如果你觉得需要内置或者有更好的实现,欢迎提交 pr |
现在的 |
https://github.com/ant-design/ant-design/blob/master/components/upload/UploadList.tsx#L77 应该是这段,但是这个地方交互上不太好处理,因为显示缩略图容易让别人以为已经上传了。所以其实 |
应该是再上两行的判断, |
这块交互还需要再讨论下 @afc163 |
我也遇到这个问题了,所以怎么不显示上传中,而是显示缩略图呢? |
@nikogu 为什么beforeUpload返回了false, 还要触发一次onChange, 不是很明白. 我需要onChange来控制图片队列的, 如删除上传失败的图片 |
我的期望是手动上传多张照片,点击上传只是选择照片执行预览,然后再通过一个特定的按钮,触发批量上传到后台,使得调用后台频率减少,数据有效性提高 我这同时还有一个bug,picture-card类型的,图片已经上传,但是还是显示上传中,代码与官方示例相同,偶现,一般上传第二个照片就正常了。应该是onChange setState时那个file的status还是loading? |
i think it's a bug.
|
@luyimei was right, |
@luyimei I am not completely agree this |
luyimei's solution solved my issue, filtering out the "file oversize" file in beforeUpload(). |
我也发现了,在beforeUpload钩子函数里面,return false并不能阻止文件的上传,但是可以用promise里面的reject(file)来阻止 |
@jYh1014 我也是这么处理的 |
+1 |
This component is probably one of the most finicky components I've ever had to work with. I wanted to validate the file without uploading to my API, and only after passing validation, can a user click an Upload button to initiate the upload. When using the @luyimei solution, the upload box border becomes red (as if it failed to upload and/or contains wrong file specifications) and ultimately looks incorrect. So... I had to basically write something like so: Example (red outline): Working example:
|
Version
2.13.7
Environment
Mac OSX 10.12.6, Chrome lastest
Reproduction link
https://codepen.io/HarlonLuo/pen/eGqrBb?editors=0010
Steps to reproduce
点击添加图片按钮,选择一个图片
What is expected?
在beforeUpload返回false后,直接显示图片缩略图
What is actually happening?
无缩略图,文字一直显示“文件上传中”
The text was updated successfully, but these errors were encountered: