[英]How can I upload a file in an FTP server using javascript?
I want to upload a file to an FTP server.我想将文件上传到 FTP 服务器。
I'm using Angular but after some research I realized that Angular has no way to upload files to FTP.我正在使用 Angular 但经过一些研究后我意识到 Angular 无法将文件上传到 FTP。 So I tried to follow this code but I didn't have any success because 'new FtpConnection()' is not recognized by javascript.
因此,我尝试遵循此代码,但没有成功,因为 javascript 无法识别“new FtpConnection()”。
Is there any other valid code to upload a file to FTP via javascript or do I need to upload the file to FTP via the backend?是否有任何其他有效代码可以通过 javascript 将文件上传到 FTP,还是我需要通过后端将文件上传到 FTP? (I use c# in backend)
(我在后端使用 c#)
JavaScript has no native mechanisms for handling input and output, including FTP communication. JavaScript 没有处理输入和 output 的本机机制,包括 FTP 通信。 It depends on the host environment to provide APIs for that.
它依赖于主机环境来为此提供 API。
Browsers (which I assume you are using given your angular tag) do not provide JS with an API for making FTP uploads, so you cannot.浏览器(我假设你正在使用你的angular标签)不为 JS 提供 API 来进行 FTP 上传,所以你不能。
(The question you reference is about JS running in Adobe Photoshop, not in a web browser). (您提到的问题是关于在 Adobe Photoshop 中运行的 JS,而不是在 web 浏览器中运行的)。
The closest you could get would be to write a web service which you could send a file to via HTTP and then have it make the FTP upload.您可以得到的最接近的方法是编写一个 web 服务,您可以通过 HTTP 将文件发送到该服务,然后让它上传 FTP。
I am a little unsure as to your question.我有点不确定你的问题。 I used this kind of interface for doing the same FTP file upload by scripts.
我使用这种接口通过脚本执行相同的 FTP 文件上传。 Please refer to this article below
请参考下面这篇文章
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.