react-component / upload Goto Github PK
View Code? Open in Web Editor NEWReact Upload
Home Page: https://upload.react-component.vercel.app/
License: MIT License
React Upload
Home Page: https://upload.react-component.vercel.app/
License: MIT License
后端要返回什么样的数据啊?
刚写的代码,onChange事件发现只有uploading 状态
你好,我在 beforeUpload中 如果抛出了Promise.reject的异常,IE和火狐等浏览器都会出现
Unhandled promise rejection的错误;
能否在源码 AjaxUploader文件里面的upload方法里面:
if(before&&before.then) { before.then(...) }
添加一个异常捕获处理?
if(before&&before.then) { before.then(...).catch((err)=>{}) }
最新版本中(2.3.7),package.json多了一个字段:"module": "./es/index",请问是什么意思?
看到内部有提供abort方法,但在外面取不到
Can I preview the image after uploaded?
data 属性没放到 form 里
I have an Upload form item that uses a customRequest. I'm getting an error when trying to leave the page:
AjaxUploader.js:185 Uncaught TypeError: Cannot read property 'abort' of undefined
at eval (webpack:///./~/rc-upload/lib/AjaxUploader.js?:185:18)
How can i manually abort the upload or signal to AjaxUploader that the request was completed through the custom request?
由于打开后是直接上传了。如果是通过data来传递表单数据.那么后台该如何获取。我后台是node.js. express;
rc-upload如何分片上传文件?
<Upload>
<input ref="xx" /> // can not get this refs when componentDidMount
</Upload>
Line 58 in 9b5b6e1
404 not found returned.
我在做ie8下的调试,但是不是很明白你们提供的IE8/9的Note的意思。
项目后端用的nodejs,目前返回的结果是
<script>document.domain="localhost"</script> + {} //发送过来的数据中好像没有domain,我这里返回“”或者null也都不可以
前端会提醒返回document.domain的script标签,并且显示拒绝访问。
后端返回的数据有问题吗
谢谢
2.0.4 版本 使用拍照上传可以成功,但是选择相册没有上传而是直接onsuccess 返回的参数为“”
IOS11上图片为HEIC格式是否支持上传?
如题,
建议判断的时候改成无法模仿的File
I couldn't find out how to limit the file size
{
uid: 'uid', // 文件唯一标识,建议设置为负数,防止和内部产生的 id 冲突
name: 'xx.png' // 文件名
status: 'done', // 状态有:uploading done error removed
response: '{"status": "success"}', // 服务端响应内容
}
file 除了这些字段还有那些?thumbUrl 是这里的吗??
fileList 的格式是这样的吗
[{
uid: -1,
name: 'xxx.png',
status: 'done',
url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
}]
event 具体是什么??
麻烦了 谢谢
@afc163
上传网络图片资源到指定服务器该怎么做呢,好像点击上传没有提供回调,都是打开本地文件
用STS临时授权的方式上传
触发场景: 使用自定义上传事件customRequest,当用户点击上传列表的取消按钮的时候报错:
reqs[uid].abort is not a function
更改AjaxUploader.jsx组件中
判断为
if (reqs[uid].abort) {
reqs[uid].abort();
delete reqs[uid];
}
修复
https://github.com/ded/reqwest
试试这个,统一下
how to cancel upload
this.refs.inner.abort is not supplied
在上传之前,有时候需要对已选择的文件进行校验,例如大小、类型等等。
目前可以在onStart中进行校验,但是校验失败时,无法阻止上传请求的发送。
In some case, the user need to get some information from the response header in OnSuccess callback.
Why not add this?
请问一下 upload 组件在 post 时候怎样在添加 headers 里面加入token 信息呢?
比如:
Authorization: Bearer .....
<iframe url='data:<form></form>'>
避免 form 嵌套
upload时有判断必须是file对象,可不可以加上Blob对象的判断
customRequest
callback 上参数上的 filename
给人直观感觉为用户所上传的文件名,而实际上却是 props.name
,比较容易误导
感觉iframe不怎么靠谱啊,各种问题。
如题,上传时没有带cookie,导致需要登录的应用在上传的时候无法成功。可否加上在请求中加上credential.
经过测试request.js中加上
xhr.withCredentials = true;
就可以
用 action 对前后端都有要求,一点都不利于扩展。
修改为一个 promise 回调这样只需要在前端处理就可以了
rt,能否根据图片exif-orientation属性进行相应的图片旋转,保持图片的正常显示
https://github.com/react-component/upload/blob/master/src/IframeUploader.jsx
Line 64 :
onChange = () => {
const target = this.getFormInputNode();
// ie8/9 don't support FileList Object
// http://stackoverflow.com/questions/12830058/ie8-input-type-file-get-files
const file = this.file = {
uid: getUid(),
name: target.value,
};
so, beforeUpload can't get file size
最近用antd Upload组件上传文件时,发现组件默认的是使用POST方法,且没有办法改,请问是否支持PUT上传文件?不支持是否有什么方案解决?谢谢
在跨域上传时出现的错误,发现来自这一行,这里是不是要做判断?
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
https://github.com/react-component/upload/blob/master/src/request.js#L68
请教下,这个问题不是很明白。
IE9,后端响应格式已经设置text/html,内容也有添加<script>document.domain=***</script>,
报参数无效。
Description is crude, and use not illustrated in example.
我的尝试是:
beforeUpload={(file) => {
const img = new Image()
img.src = URL.createObjectURL(file)
img.onload = () => {
// ... 进行 naturalWidth, naturalHeight 检测
}
}}
但是在 onload
时,没有办法在 beforeUpload
里 return false
,
只能够在上传完成后进行宽高检测吗?
现在 Upload 在 node 环境下渲染会用 IframeUploader,浏览器下渲染会用 AjaxUploader,导致两边渲染结果不同,做 SSR 的时候 React 会有警告。
阿里OSS上传文件忽略file字段之后的参数,amazon s3同样存在该问题
request.js 39行放到44行后面可以解决。
Line 53 in 0d4054c
这个地方不应该写成只能是200吧,例如 204 no content 之类的,也应该允许为success
for (const key in data) { if (data.hasOwnProperty(key)) { inputs.push(
); } }
源代码中这里用拼字符串的方式插入表单节点,如果data[key]中有双引号,会造成值设置失败。
建议改成createElement之后设置value的方式插入节点。
While uploading, I wanted a button which on clicking aborts the upload process.
I guess onProgress must be having something which does this.
I tried returning false or empty promise in onProgress, which doesn't works.
Thanks
<form>
<Upload />
<form>
ie9 渲染出错,需要将 upload form 移到 body 上然后绝对定位
问题如标题所述。调试信息如下图,https://github.com/react-component/upload/blob/master/src/AjaxUploader.jsx#L29 el.value = '';
执行后无效果。
IE11 和其他主流浏览器中未发现此问题。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.