asp.net mvc的在iframe返回一个图像 [英] asp.net mvc returning an image in an iframe

查看:142
本文介绍了asp.net mvc的在iframe返回一个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从上传控制器返回一个完整的图像我想要什么。我想显示完整的图像返回为IFRAME响应的一部分。这里是我的看法code得到的想法。能不能做到?目前,它返回一个字符串,文件上传或不?

 <形式的行动=<%= Url.Action(文件上传,本组织)%GT;方法=POSTENCTYPE =的multipart / form-data的TARGET =uploadresult的onsubmit =返回showStatus()>
           <输入类型=文件ID =名称=A/>            < IFRAME ID =uploadResultNAME =uploadresultWIDTH =200FRAMEBORDER =0HEIGHT =100的onload =showResult();风格=visibility:hidden的>
            < / IFRAME>


解决方案

 返回新FileStreamResult(新的FileStream(CompletePhysicalPath,FileMode.Open),图像/ JPEG);

what i want i want to return a complete image from the controller that is uploaded. i want to display the complete image returning as the part of iframe response. here is my view code to get the idea. can it be done? Currently it is returning a string that a file is uploaded or not?

  <form action="<%= Url.Action("FileUpload", "Organization")%>" method="post" enctype="multipart/form-data" target="uploadresult" onsubmit="return showStatus()">
           <input type="file" id="a" name="a" />



            <iframe id="uploadResult" name="uploadresult"  width="200" frameborder="0" height="100" onload="showResult();" style="visibility:hidden">                  
            </iframe>

解决方案

   return new FileStreamResult(new FileStream(CompletePhysicalPath, FileMode.Open), "image/jpeg");

这篇关于asp.net mvc的在iframe返回一个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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