c# - HttpPostedFileBase returns null after submitting -


i keep on getting null httpposterfilebase when try uploading file:

i have code in view:

@using (html.beginform("import", "control", formmethod.post, new { enctype = "multipart/form-data" })) {     <input type="file" name="fileupload"/>     <input type="submit" value="import" id="btnimport" class="button" /> } 

and code controller:

[httppost] public actionresult import() {          httppostedfilebase file = request.files[fileupload];                  other codes... } 

i tried in controller:

[httppost] public actionresult import(httppostedfilebase fileupload) {             other codes... } 

after pressing submit button "file" got value of null.

the default model binder binds name files. inputs name fileupload.. parameter name file. making them same work.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -