Support Topics Documentation Slack YouTube Blog

File upload using React (Create-react-app boilerplate)


(Shaiv Kamat) #1

setupFiles = () => {
const filePath = serverURL + “files/profileData/”;
const suffix = “.txt”;
const self = this;
let data = {
name: “stuff”

let profileData = new FormData();
profileData.append("file", data);
profileData.append("name", { name: "profileData" });
  "profileData/" + self.props.getUser().ObjectId
  .then(function(fileURL) {
    console.log("RESPONSE", fileURL);
  .catch(function(error) {
    console.log("error", error);


This runs after the user logs in, so the Backendles app is Initialized correctly. I just want to create and upload a file to the server using React and I keep getting

[Error: Wrong type of the file source object. Can not get file name].

I think this might be a React issue since it is a FrontEnd dev platform, but maybe I am not formatting the FormData correctily, and I can’t find another solution that doesn’t require the user to upload their own files to modify.

Any help would be appreciated.

(Mark Piller) #2

Hello Shaiv,

Per the Backendless File Upload documentation, the first argument of the upload method must be JS’s File object:

I suspect the problem occurs because of the type mismatch in your code.