图像未在视图中显示? [英] Image is not being showed in the view?

查看:78
本文介绍了图像未在视图中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生/女士

i在我的视图中使用tinymce编辑器,我正在使用编辑器中编写的其他内容保存图像。

问题是当我显示在视图中的内容然后显示所有内容,留下图像。



这是我的控制器代码

Dear sir/madam
i am using tinymce editor in my view and i am saving the image with other content written in editor.
the problem is when i show the content in view then all the content are displayed leaving the image.

Here is my code of controller

public JsonResult upload()
       {
           var file = Request.Files["file"];
           //string extension = Path.GetExtension(file.FileName);
           //string fileid = Guid.NewGuid().ToString();
           //fileid = Path.ChangeExtension(fileid, extension);
           var filename1 = Path.GetFileName(file.FileName);
           string locationn = Server.MapPath(@"~/Uploads/img/" + filename1);
           file.SaveAs(locationn);
           //HttpPostedFileBase f1 = Request.Files["f1"];
           //var filename1 = Path.GetFileName(f1.FileName);
           //var p1 = Server.MapPath("~/contnt/images/" + filename1);
           //f1.SaveAs(p1);
           //var pic1 = Url.Content(Path.Combine("~/contnt/images/" + filename1));
           return Json(new {location= Url.Content(Path.Combine("~/Uploads/img/" + filename1))}, JsonRequestBehavior.AllowGet);
      }





这是查看代码



this is View code

<div class="content table-responsive table-full-width">
    <link href="~/Scripts/Uploadify/uploadify.css" rel="stylesheet" />
    <script src="~/Scripts/UPLODIFY/jquery.uploadify.min.js" type="text/javascript"></script>
    <script src="~/Scripts/tinymce/tinymce.min.js"></script>
    <script>
tinymce.init({
selector: 'textarea',
height: 500,
theme: 'modern',
skin: "lightgray",
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools'
],
toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image',
toolbar2: 'print preview media | forecolor backcolor emoticons ',
    //image_advtab: true,
images_upload_url: '/Account/upload',
images_upload_credentials: true,
automatic_uploads: true
});
    </script>
    @*<script src="~/Scripts/jquery-1.10.2.js"> </script>
    <script type="text/javascript">
        $(function(){
            $("[name=filee]").on("change", function ()
            {
                var file=$(this).val()
                alert(file)
                $.ajax({
                    type: 'get',
                    url: '/Account/upload'
                    });
            });
        });
    </script>*@
               @using (Html.BeginForm("AddNews", "Account", FormMethod.Post,new { enctype = "multipart/form-data"}))
               {

                    <table class="table table-striped">
                      <tbody>
                            <tr><td>@Html.DropDownList("newstype",new SelectList(Enum.GetValues(typeof(newsportal.Models.newstype))),new {id="ntype"})</td></tr>
                            <tr><td>Date</td><td>@Html.TextBoxFor(Model => Model.datee, new { @type = "date",paceholder="select date"})</td></tr>
                            <tr><td>Country</td><td>@Html.TextBoxFor(Model => Model.country)</td></tr>
                            <tr><td>State</td><td>@Html.TextBoxFor(Model => Model.statee)</td></tr>
                            <tr><td>City</td><td>@Html.TextBoxFor(Model => Model.city)</td></tr>
          <tr><td>Category</td><td>@Html.DropDownListFor(Model=>Model.cat, new SelectList(Enum.GetValues(typeof(newsportal.Models.category))),"Select Category")</td></tr>
                            <tr><td>SubCategory</td><td>@Html.TextBoxFor(Model => Model.subcat)</td></tr>
                           <tr><td>URL Title(only for hindi news)</td><td>@Html.TextBoxFor(Model=>Model.urltitle)</td></tr>
                          <tr><td>Enter The News Youtube Url</td><td>@Html.TextBoxFor(Model=>Model.videourl)</td></tr>
                            <tr><td>Title</td><td>@Html.TextAreaFor(Model => Model.title)</td></tr>  
                           <tr><td>Content</td><td>@Html.TextAreaFor(Model => Model.content)</td></tr>
                            <tr><td>pic1</td><td><input name="f1" type="file" /></tr>
                            <tr><td>Writer</td><td>@Html.TextBoxFor(Model => Model.writ)</td></tr>
                            <tr><td><input type="submit" /></td></tr>
                      </tbody>
                     </table>
               }
</div>





这是我显示内容的视图





this is the view where i display the content

<pre>div class="content_bottom_left">
        <div class="single_page_area">
            <h2 class="">@ne.title</h2>
            <div class="single_page_content">
                <div class="post_commentbox"> <a href=@Url.Action("Home","News")>@ne.writ</a> <span>@ne.datee</span> <a href="#">@ne.cat</a> </div>
                <img class="img-center" src=@ne.pic1 alt="" style="height:430px;">
                @Html.Raw(ne.content)
            </div>





我是什么尝试过:



i没有尝试任何其他方法。



What I have tried:

i didnot tried anything else laving this.

推荐答案

(功能( ){


([name = filee])。on(change,function()
{
var file =
("[name=filee]").on("change", function () { var file=


(this).val()
alert(file)
(this).val() alert(file)


这篇关于图像未在视图中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆