如何上传文件到后端服务器?

I want to upload videos and images and store them in the server's folder. The server will be of the client whose website it is. How to perform this? I was following this link wherein service I changed the endpoint URL to for timing http://localhost:4200/assets/. But I realized that it can only take https://master.tus.io/files/ as it's a tus.io's library.

评论
ramet
ramet

Sending a file from a client to a server is a novel challenge, the implementation for the client is very similar to the server, you're accepting form-data from your user (uploading to Angular), now you need to forward that form-data in a request to your back-end.

为了提供任何示例,我需要有关您的后端的更多信息,因此,我将提供一些有用的资源:

What you're looking to achieve (at a high-level), is to send a file to a remote server using form-data as the content-type from Angular, x-www-form-urlencoded or application/json won't provide the support of sending files. (AFAIK).

如果您可以提供有关任何要求的更多详细信息,那将有很大帮助,例如:您将其发送到哪个服务器?当然,FTP是一种选择,尽管服务器可以将文件作为电子邮件发送到电子邮件服务器。

你看到那里有些混乱吗?我的回答是基于您正在尝试将数据发送到远程后端API(可能是使用JSON的REST)的假设。

点赞
评论