尝试在redactor中上传图片

时间:2018-06-07 20:38:31

标签: c# json redactor redactor.js

我尝试根据以下页面在redactor中上传图片: https://imperavi.com/redactor/docs/how-to/upload-images/

图像文件正在上传很好,但是它没有返回到图像的正确路径,因此在编辑器中我只得到以下随机数据图像"在我的HTML img中:

<img data-image="3bmpsdp1fgff">

以下是我的控制器中的代码:

public ActionResult ImageUpload()
{
    string filePath = "/myPath/";

    HttpPostedFileBase file = null;
    if (Request.Files.Count > 0)
    {
        file = Request.Files[0];
    }

    if (file != null && file.ContentLength > 0)
    {
        var fileName = Path.GetFileName(file.FileName);
        var path = Server.MapPath(filePath + fileName);
        file.SaveAs(path);
    }

    return Json(new { filelink = filePath + file.FileName });
}

提前致谢。

0 个答案:

没有答案