Problem to save image to Node and React

Asked

Viewed 303 times

0

I am trying to upload images to my server using Node and React, however, when trying to upload, it generates this message:

Not allowed to load local Resource: file://C:/fakepat:3000/record/1h/pastedImage.png

I can’t understand what it might be, someone to help me?

inserir a descrição da imagem aqui

React

handleAdd() {
    const id = this.state.id;
    const image = this.state.image;
    const description = this.state.description;
    const patient = this.state.patient;

    if (id === '') {
        axios.post(URL, { image, description, patient })
            .then(resp => this.refresh());
    } else {
        axios.put(`${URL}/${id}`, { image, description, patient })
            .then(resp => this.refresh());
    }
}

Node

router.post('/', async(req, res, next) => {
    try {
        var record = new Record({
            image: req.body.image,
            description: req.body.description,
            patient: req.body.patient
        });
        await record.save();
        res.status(201).send({
            message: 'Cadastro efetuado com sucesso!'
        });
    } catch (e) {
        res.status(500).send({
            message: 'Falha ao processar sua requisição'
        });
    }
});
  • 1

    Put the source code to save please

  • Probably the folder you are trying to write the file that went up to the server, not write permission for Node. Maybe a chmod 775 upload already solve.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.