开发者

How can I read an xml file from the users computer on an ASP.NET MVC2 site?

开发者 https://www.devze.com 2023-01-08 08:09 出处:网络
I am writing a website to consolidate a bunch of XML files with data into one MySQL database. I need to have a way to allow users to select a directory on their computer that contains a bunch of xml f

I am writing a website to consolidate a bunch of XML files with data into one MySQL database. I need to have a way to allow users to select a directory on their computer that contains a bunch of xml files. The site then reads each of those files and takes care of consolidating the information.

Is there a simple way (like the default open file dialog for win forms and wpf) to bring up a file dialog on a users computer, let the user pick a directory, and then be able to read the xml files in the selected directory? Would I have to upload them to the site temporarily first? Or could I just access them on the 开发者_运维问答users computer?

Thanks!!


You can't access files from a webserver directly. You would need to write an ActiveX Control if you really don't find another way.

The standard conform way it just uploading one or more files with the browser fileupload: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

I would suggest that the user should zip the files and just upload the zip file.

There are some hacks - but I don't think it fits:

  • http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
  • http://dotnetslackers.com/articles/aspnet/Upload_multiple_files_using_the_HtmlInputFile_control.aspx


I think you have to have a web dialog to upload the files to a temp location like you already mentioned and do the consolidation there before committing to your database. Or, maybe you can do the consolidation in JavaScript in the user's browser instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消