Programmatically set name of file to upload in webpage(以编程方式设置要在网页中上传的文件名)
问题描述
有没有办法以编程方式设置要从网页上传的文件的名称?我怀疑浏览器安全限制使这不可能,但我希望有人能证明我错了.
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.
这篇关于以编程方式设置要在网页中上传的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式设置要在网页中上传的文件名
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
