問題描述
有沒有辦法以編程方式設(shè)置要從網(wǎng)頁上傳的文件的名稱?我懷疑瀏覽器安全限制使這不可能,但我希望有人能證明我錯了.
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 應(yīng)用程序.管理員選擇 HTML 文件,然后應(yīng)用程序上傳該文件,并找出所有支持文件(圖像、樣式表等)并上傳它們.似乎沒有辦法以編程方式從網(wǎng)頁上傳支持文件,因?yàn)橛脩舯仨毭鞔_指定每個文件.
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.
目前我有一個單獨(dú)的 Windows 應(yīng)用程序來執(zhí)行此操作,但最好將此功能與應(yīng)用程序的其余部分集成.我的后端是帶有 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#.
推薦答案
無法通過瀏覽器以編程方式從用戶計(jì)算機(jī)中抓取文件.如果網(wǎng)站只能抓取東西,這將違反安全規(guī)定.
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.
這篇關(guān)于以編程方式設(shè)置要在網(wǎng)頁中上傳的文件名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!