以编程方式上传文件

发布于 2024-10-06 09:59:14 字数 98 浏览 3 评论 0原文

我可以以编程方式将文件上传到服务器(不受客户端干扰)吗?我知道这在普通(.html)文件中是不可能的。无论如何,我可以从 .hta 文件中做到这一点吗?或任何服务器端或插件解决方案?

Can I programmatically upload a file to the server (without client's interference) ? I know this is not possible in normal (.html) files. Is there anyway I can do it from .hta file? or any server side or plug-gin solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鲜肉鲜肉永远不皱 2024-10-13 09:59:14

从 HTA 中,您可以使用 shell 对象来运行命令,就像从命令行运行一样 - 包括 FTP - 但当然您需要 FTP 凭据。既然你说你将能够对要上传的文件进行硬编码,我假设你拥有完全访问权限......

var shell = new ActiveXObject('wscript.shell');
var params = // this should be a string of ftp commands, like OPEN ftp.example.com USER PASS CWD somedir PUT c:\whatever.txt BYE
shell.run("%comspec% /c ftp.exe -i -s:" + params, 1, true);

from an HTA, you can use the shell object to run commands just as if you were running from the command line - including FTP - but of course you'll need FTP credentials. since you said you'll be able to hardcode the files to be uploaded, i assume you have full access...

var shell = new ActiveXObject('wscript.shell');
var params = // this should be a string of ftp commands, like OPEN ftp.example.com USER PASS CWD somedir PUT c:\whatever.txt BYE
shell.run("%comspec% /c ftp.exe -i -s:" + params, 1, true);
酒浓于脸红 2024-10-13 09:59:14

简短的回答是否定的。

一些机器上使用签名的java小程序可能是可能的 - 但从问题的措辞来看,这对你来说将是一个非常漫长的旅程。

Short answer is no.

It may be possible on some machines using a signed java applet - but from the wording of the question, that's going to be a very long juorney for you.

流心雨 2024-10-13 09:59:14

根据您最后的评论,您可能至少需要用户加载网页。因此,基于 onload 函数,您可以使用 ajax 隐藏表单来提交您想要的任何文件。

但在用户不知情的情况下获取信息可能会让您陷入法律困境。

祝你好运!!

Based on your last comment, you might atleast need the user to load a web page. So based on an onload function, you can use an ajax hidden form to submit whatever files that you'd want to.

But getting information from your user without their knowledge might put you in a legal situation.

Good luck!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文