簡體   English   中英

以注冊Asp.NET身份上傳

[英]Upload with Register Asp.NET Identity

我正在嘗試編輯默認的Register方法,以在我的ASP.NET MVC 5應用程序中啟用用戶在注冊過程中上傳文件。 我已經將控制器編輯為:

public async Task<ActionResult> Register(RegisterViewModel model, HttpPostedFileBase file1, HttpPostedFileBase file2)
{
    if (ModelState.IsValid)
    {

鑒於我有這個:

<div class="form-group">
    <label class="control-label col-md-2" for="AssignmentPath">Assignment: </label>
<div class="col-md-10">
        <input id="AssignmentPath" title="Submit your assignment" type="file" name="file1" />

    </div>
</div>

    <div class="form-group">
        <label class="control-label col-md-2" for="FontPath">Font : </label>
<div class="col-md-10">
        <input id="FontPath" title="Submit your font" type="file" name="file2" />

    </div>
</div>

調試代碼時,我發現Controller中的file1和file2均為空。 你能告訴我問題是什么嗎? 謝謝。

您的觀點應該是這樣的

    @using (Html.BeginForm ("Index","Home", FormMethod.Post,  
                            new { enctype = "multipart/form-data" }))  
    {                    
         <input type="file" name="file1" />
         <input type="file" name="file2"/>
         <input type="submit" value="Upload file"/>
    } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM