J
J
jazzus2019-04-26 17:35:54
Vue.js
jazzus, 2019-04-26 17:35:54

How to send a file along with other data?

There are 2 objects.

project {name, description}
file

i need to embed the file in the project structure so that the request looks like this
{
name,
description,
file {}
}

Those. the file is embedded in project.
I'm writing the wrong code at the moment
let project = new FormData();
project.append(this.project);
project.append("file", this.file)

I post it in such a way that the direction of thoughts is clear. Wrong because I need to specify two values, but I don't want to put the project in a separate object. How to fix the code to get the desired structure of the request? Back Laravel, the file must be received as a file

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question