Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用LINQ上传图像_C#_Linq_Image Uploading - Fatal编程技术网

C# 使用LINQ上传图像

C# 使用LINQ上传图像,c#,linq,image-uploading,C#,Linq,Image Uploading,我正在尝试将图像上载到数据库。我的代码如下: 我得到以下错误: 输入不是有效的Base-64字符串,因为它包含非Base-64字符串 字符、两个以上填充字符或非法字符 在填充字符中 我怎样才能让它工作 查看 <div class="form-group"> @Html.LabelFor(model => model.image, new { @class = "control-label col-md-2" }) <div clas

我正在尝试将图像上载到数据库。我的代码如下:

我得到以下错误:

输入不是有效的Base-64字符串,因为它包含非Base-64字符串 字符、两个以上填充字符或非法字符 在填充字符中

我怎样才能让它工作

查看

    <div class="form-group">
        @Html.LabelFor(model => model.image, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.TextBoxFor(model => model.image, new { @class = "form-control", type = "file", placeholder = "image" })
            @Html.ValidationMessageFor(model => model.image)
        </div>
    </div>
控制器

public async Task<ActionResult> Create([Bind(Include="")] Profile profile)
{
    if (ModelState.IsValid)
    {
            var pro= new Profile{ image = profile.image};
            db.Profile.Add(pro);

            await db.SaveChangesAsync();
            return RedirectToAction("sucess");
    }
    return View(profile);
}

public async Task

此任务的可能重复项可能与此相关:我看不到您的代码中出现任何base64编码。请显示发送到服务器的base64编码字符串/尝试保存在db中,好吗?或者您实际上不(希望)将图像作为base64编码字符串发送?然后,您应该看看.net流媒体api。无论如何,我认为您的问题是在模型中使用byte[]。尝试使用
HttpPostedFileBase
代替:)编辑:如其他注释所示。对不起,我是新手。有人能给我举个例子吗?林克和这个有什么关系?
public async Task<ActionResult> Create([Bind(Include="")] Profile profile)
{
    if (ModelState.IsValid)
    {
            var pro= new Profile{ image = profile.image};
            db.Profile.Add(pro);

            await db.SaveChangesAsync();
            return RedirectToAction("sucess");
    }
    return View(profile);
}