问题描述
有没有办法以编程方式设置要从网页上传的文件的名称?我怀疑浏览器安全限制使这不可能,但我希望有人能证明我错了.
Is there a way to programmatically set the name of a file to be uploaded from a web page? I suspect that browser security restrictions make this impossible, but I'm hoping someone will prove me wrong.
我有一个需要让管理员上传 HTML 的 Web 应用程序.管理员选择 HTML 文件,然后应用程序上传该文件,并找出所有支持文件(图像、样式表等)并上传它们.似乎没有办法以编程方式从网页上传支持文件,因为用户必须明确指定每个文件.
I have a web application that needs to let the administrator upload HTML. The admin selects the HTML file, then the app uploads that file, plus figures out all the supporting files (images, stylesheet, etc) and uploads them too. There doesn't seem to be a way to programmatically upload the supporting files from a web page, since the user has to specify each file explicitly.
目前我有一个单独的 Windows 应用程序来执行此操作,但最好将此功能与应用程序的其余部分集成.我的后端是带有 C# 的 ASP.NET.
Currently I have a separate Windows app to do this, but it would be ideal to have this functionality integrated with the rest of the app. My back end is ASP.NET with C#.
推荐答案
无法通过浏览器以编程方式从用户计算机中抓取文件.如果网站只能抓取东西,这将违反安全规定.
There is no way to programatically grab files from a user's computer via the browser. This would be a security violation if a website could just grab things.
这篇关于以编程方式设置要在网页中上传的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!