douhuo1738 2019-07-16 16:12
浏览 121

我应该如何构建对Vue.js上传的后端响应?

(Context: Building a company site with an admin portal that allows the user to make new team members, jobs, etc. and have the web app reflect those changes.)

I have a Vue.js web app that is hosted on a server (let's say GoDaddy or BlueHost), and I want to be able to upload pdf's and images to that same server, then reference those files elsewhere in the web app. I am comfortable in the frontend, and have figured out how to make an upload component that allows for a selection of a file, then an axios post.

Here is where my confusion begins...

First of all, I imagine it must be possible to upload files to my server and store them there.

Next, I think that I should be able to put some code (either PHP or Express or something) somewhere on the server to accept those storage requests.

Finally, I think that code would probably need to be in the root of the web app so that the web app can easily reference it.

(Side note: I have already tried Google Cloud Functions, and while they let me store images in Firebase, I couldn't figure out how to reference those photos in the web app. I have also tried to use Express to set up an api endpoint, but I am getting stalls on every post request via Postman, and I am not sure how to troubleshoot it.)

Can someone just outline what is supposed to happen, from the axios post on, and give me a basic idea of what the structure of this should look like?

I am open to learning whatever I need to make this happen.

  • 写回答

1条回答 默认 最新

  • doushijiao0679 2019-07-16 16:44
    关注

    send file to server with 'Content-Type': 'multipart/form-data' header in post method using axios as described here

    use multer npm for handle uploading file to server .

    example link here

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog