Skip to content

Commit

Permalink
fix(upload): add name parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
BQXBQX committed Apr 1, 2024
1 parent bd48052 commit 448dc43
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/ui-react/lib/Upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export interface UploadProps extends React.HtmlHTMLAttributes<HTMLInputElement>
* formdate
*/
formData?: FormData;
/**
* Parameter name of the file sent to the backend default is name
*/
name?: string;
}

const customEase = [0.215, 0.61, 0.355, 1];
Expand All @@ -78,6 +82,7 @@ export const Upload = React.forwardRef<HTMLInputElement, UploadProps>(
customRequest,
multiple = false,
formData = new FormData(),
name = 'file',
...rest
},
ref,
Expand All @@ -103,12 +108,11 @@ export const Upload = React.forwardRef<HTMLInputElement, UploadProps>(
}, [uploadFiles, onchange, addUploadFiles]);

const handleUpload = (files: File[]) => {
files[0] && formData.append('file', files[0]);
files[0] && formData.append(name, files[0]);
fetch(action, {
method: method,
body: formData,
headers: headers,
mode: 'no-cors',
})
.then((res: object) => {
console.log(res);
Expand Down

0 comments on commit 448dc43

Please sign in to comment.