Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost("upload")]
- public virtual async Task<IActionResult> PostMulti(Int64 parentId, ICollection<IFormFile> fileData)
- {
- foreach (var file in fileData) {
- await SaveFile(file, parent);
- }
- return Created("", Map(Repository.Get(parentId)));
- }
- const formData = new FormData();
- formData.append('image', this.state.file);
- console.log("this.state.file = ", this.state.file);
- console.log("formData = ", formData);
- axios({
- url: `/api/gameMethods/playerStates/${this.props.playerId}/files/upload`,
- method: 'POST',
- data: formData,
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'multipart/form-data'
- }
- })
- .then((response) => {
- //handle success
- console.log('response -- then: ', response);
- this.setState({
- file: this.state.file
- });
- })
- .catch((response) => {
- //handle error
- console.log('response -- catch: ', response);
- });
- const filesToSubmit = []
- filesToSubmit.push((new FormData()).append('image', this.state.file))
- axios({
- url: `/api/gameMethods/playerStates/${this.props.playerId}/files/upload`,
- method: 'POST',
- data: {formData : filesToSubmit},
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'multipart/form-data'
- }
- })
- axios({
- url: myUrl,
- method: 'POST',
- data: `email=${myEmail}`,
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- })
- .then(response => {
- console.log(response);
- })
- .catch(error => {
- console.error(error);
- });
Add Comment
Please, Sign In to add comment