views:

27

answers:

2

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!!

+1  A: 

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:

Andreas Rehm
Cool, thanks! I look into those.
evan
I think I'm going to go with the fileupload control. is there any reason not to using a web control with MVC? (I have some experience with ASP.NET but JUST started the ASP.NET MVC) Thanks!
evan
No - it should work with MVC too - by the way - Telerik provides open source MVC Controls: http://telerikaspnetmvc.codeplex.com/
Andreas Rehm
A: 

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.

JohnB