Recently I have been messing around with superagent in a project of mine and got to a road block. I am trying to send files via ajax to my Laravel PHP backend but I can't seem to receive anything on the backend side. I have been using superagents 'attach' method with no success.
Javascript (ES6)
createProject(input) {
Request.post(domain + '/projects')
.withCredentials()
.field('project', input.project)
// Truncated for brevity
.attach('image', input.image)
.end(function (err, res) {
// Do something
}.bind(this));
}
When I check the PHP backends received data I get an array of everything excluding the posted file.
Any help is appreciated!
You can send a file via
superagent
using it'ssend
method.Please note that
input.file
is a instance of File.