Comments (4)
加上polyfill ie9下直接报错。
不加polyfill,可以使用,但是返回结果后会error。追踪是这段代码有问题,因为服务器返回的是一段json,没有script,而这里 const script = doc.getElementsByTagName('script')[0]; 取script,导致undefined。 怎么解决?
onLoad = () => {
if (!this.state.uploading) {
return;
}
const { props, file } = this;
let response;
try {
const doc = this.getIframeDocument();
const script = doc.getElementsByTagName('script')[0];
if (script && script.parentNode === doc.body) {
doc.body.removeChild(script);
}
response = doc.body.innerHTML;
props.onSuccess(response, file);
} catch (err) {
warning(false, 'cross domain error for Upload. Maybe server should return document.domain script. see Note from https://github.com/react-component/upload');
response = 'cross-domain';
props.onError(err, null, file);
}
this.endUpload();
}
from upload.
@joybee007 引入了什么 polyfill ?
from upload.
就加一个 native code 判断可以么,比如这样
typeof FormData !== 'undefined' && FormData.toString().indexOf('[native code]') > -1
from upload.
@shepherdwind 一个模拟FormData的插件。然而并不支持文件上传。native code判断也算不是方法的方法吧。建议判断浏览器的File类,这个暂时无法模拟~所以几乎不会有人做一个这个polyfill吧。
from upload.
Related Issues (20)
- 拖拽上传无法禁用文件夹
- 选300多张图片的时候非常卡,而且canvas会创建出20000+个
- Parsed File shape is incorrect on certain platforms HOT 1
- Feature Request: Choose and Upload later
- Android手机无法选择视频上传
- Typescript: make arguments optional
- duplicated parameter: capture
- Feature request: re-upload trigger
- Coding
- return U-Id don't accepted in file preview
- How to trigger upload from external button element HOT 1
- upload组件的method是不是没什么意义,改put也不能有效上传form-data格式的数据
- 拖拽上传含有多个文件的文件夹时,beforeUpload无法获取全部文件,点击上传时可以,这是bug吗?
- chrome最新版本点击无效(无法唤起文件选择) HOT 1
- disabled属性需要作用到input上
- Clock pyrhon
- Support directory AND file uploads via Drag-and-Drop HOT 1
- upload a directory which size is very bigger(above 100G), this component will make the chrome memory usage to exceed 2G, and the crash
- 开启文件夹上传时就不能多选文件上传,可以解决吗?
- 4.3.6版本 更改了内部的 click 事件导致生产报错了 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from upload.