Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ React.render(<Upload />, container);
|onSuccess | function | | success callback |
|onProgress | function || progress callback, only for modern browsers|
|beforeUpload| function |null| before upload check, return false or a rejected Promise will stop upload, only for modern browsers|
| withCredentials | boolean | false | ajax upload with cookie send |

#### onError arguments

Expand Down
2 changes: 2 additions & 0 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const AjaxUploader = React.createClass({
onStart: PropTypes.func,
data: PropTypes.object,
beforeUpload: PropTypes.func,
withCredentials: PropTypes.bool,
},

onChange(e) {
Expand Down Expand Up @@ -85,6 +86,7 @@ const AjaxUploader = React.createClass({
filename: props.name,
file: file,
data: data,
withCredentials: props.withCredentials,
onProgress: e => {
props.onProgress(e, file);
},
Expand Down
2 changes: 2 additions & 0 deletions src/Upload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Upload = React.createClass({
accept: PropTypes.string,
multiple: PropTypes.bool,
beforeUpload: PropTypes.func,
withCredentials: PropTypes.bool,
},

getDefaultProps() {
Expand All @@ -33,6 +34,7 @@ const Upload = React.createClass({
onSuccess: empty,
multiple: false,
beforeUpload: null,
withCredentials: false,
};
},

Expand Down
2 changes: 1 addition & 1 deletion src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function upload(option) {
option.onSuccess(getBody(xhr));
};

if ('withCredentials' in xhr) {
if (option.withCredentials && 'withCredentials' in xhr) {
xhr.withCredentials = true;
}

Expand Down