問題描述
有沒有辦法以編程方式設置要從網頁上傳的文件的名稱?我懷疑瀏覽器安全限制使這不可能,但我希望有人能證明我錯了.
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.
這篇關于以編程方式設置要在網頁中上傳的文件名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!