Last active
February 28, 2022 07:14
-
-
Save Lxxyx/cfbed86f7957064876f8115ecbe3db77 to your computer and use it in GitHub Desktop.
Upload RFC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Api, | |
Post, | |
} from '@midwayjs/hooks' | |
import { | |
File, | |
useFiles | |
} from '@midwayjs/upload' | |
export default Api( | |
Post('/api/upload'), | |
File(), | |
async () => { | |
const files = useFiles() | |
console.log(files[0].name) | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import upload from './api' | |
const form = new FormData() | |
const file = document.querySelector('input[type="file"]') | |
form.append('file', file.files[0]) | |
upload({ formData: form }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment