c# - Uploading file in with ASP.NET MVC3 (OpenFileDialog alternative) -


i'm trying replicate webforms functionality uploads csv file in mvc3 project , coming unstuck. have following requirements:

(short version need similar filter, initialdirectory , preferably not necessarily, multiselect properties of system.windows.controls.openfiledialog class mvc3)

  1. single button displayed opens open file dialog
  2. upload begins when open clicked in dialog
  3. the file type in dialog should restricted csv, txt , files
  4. the initial directory should able set depending on user preferences

i've used jquery first 2 requirements (shown below) not if best way or how accomplish last two.

view:

@using (html.beginform("import", "date", formmethod.post, new { enctype = "multipart/form-data", id="fileupload" })) {     <input type="file" name="file" id="file" style="display: none;" />     <input type="button" id="import" value="import" /> }  <script type="text/javascript">     $(document).ready(function () {          $('#file').change(function () {             $('#fileupload').submit();         });          $('#import').click(function () {             $('#file').trigger('click');         });      }); </script> 

controller:

[httppost] public actionresult import(httppostedfilebase file) {       // stuff } 

any ideas?

it's not possible unless use flash or silverlight plugin. use uploadify , should need.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -