MVC無重新整理上傳圖片並顯示

來源:互聯網
上載者:User

標籤:style   blog   java   color   width   io   

@{    ViewBag.Title = "Home Page";}<script src="../../Scripts/swfobject.js" type="text/javascript"></script><script src="../../Scripts/jquery.uploadify.v2.1.4.js" type="text/javascript"></script><link href="../../Content/uploadify.css" rel="stylesheet" type="text/css" /><script type="text/javascript">    $(document).ready(function () {        $("#uploadify").uploadify({            ‘uploader‘: ‘/content/uploadify.swf‘,            ‘script‘: ‘/Home/Upload‘,            ‘cancelImg‘: ‘/content/cancel.png‘,            ‘folder‘: ‘UploadFile‘,            ‘queueID‘: ‘fileQueue‘,            ‘auto‘: false,            ‘multi‘: true,            ‘onComplete‘: function (event, ID, fileObj, response, data) {                $(‘#div_img‘).after("&nbsp;&nbsp;&nbsp;<img src=" + response + " alt=‘‘ height=‘100‘ width=‘100‘ />")            }        });    });  </script><div id="div_img"></div><div>    <div id="fileQueue" style="text-align: center">    </div>    <input type="file" name="uploadify" id="uploadify" />    <p>        <a href="javascript:$(‘#uploadify‘).uploadifyUpload()">上傳</a>&nbsp; <a href="javascript:$(‘#uploadify‘).uploadifyClearQueue()">            取消上傳</a>    </p></div>
public string Upload(FormContext from)        {            var file = Request.Files["Filedata"];            string uploadPath = Server.MapPath("~/images/");            string url = "/images/" + file.FileName;            if (file != null)            {                                file.SaveAs(uploadPath + file.FileName);                             return url;//返回儲存的地址            }            else            {                return "0";            }                     }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.