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)
- single button displayed opens open file dialog
- upload begins when open clicked in dialog
- the file type in dialog should restricted csv, txt , files
- 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
Post a Comment