如何使用asp.net和c#动态上传和显示网页上的多个图像。 [英] how to upload and display the multiple images on webpage dynamically using asp.net and c#.

查看:112
本文介绍了如何使用asp.net和c#动态上传和显示网页上的多个图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在aspx图像中显示图像。请帮助我。!!

以下我附上了我的代码。







FRONT END

i cant able to display the images in aspx image. please help me.!!
below i have attached my code below.



FRONT END

<form id="form1"  runat="server">
    <div>
    <asp:FileUpload AllowMultiple="true" ID="fileuploadimages" runat="server" />
    <asp:Button runat="server" ID="btnUpload" CssClass="btnStyle" Text="Upload Image"
        OnClick="btnUpload_Click" />
    <asp:Label ID="listofuploadedfiles" runat="server" />
    <div id="dvGallery"  runat="server">

    </div>
    </div>
    </form>





代码背后



CODE BEHIND

public partial class galle4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateImage();
        }
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (fileuploadimages.HasFiles)
        {
            foreach (HttpPostedFile uploadedFile in fileuploadimages.PostedFiles)
            {
                uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/images/"),
                uploadedFile.FileName));
                listofuploadedfiles.Text = string.Format("updated successfully");
            }
            PopulateImage();
        }
    }
    private void PopulateImage()
    {
        DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/Images"));
        foreach (var i in dir.GetFiles())
        {
            dvGallery.InnerHtml = "<img src='~/Images + file.Name'/>";
        }
    }
}

推荐答案

请参考此链接: -



http://www.aspsnippets.com/Articles/HTML5-Show-Display-multiple-image-preview-before-upload-with-FileUpload-control-using-JavaScript-and -jQuery.aspx [ ^ ]



http://jqueryasp.net/upload-multiple-image-file-progress-bar-asp-net -using-jquery / [ ^ ]



http:// www。 c-sharpcorner.com/uploadfile/prathore/multiple-image-upload-in-Asp-Net/ [ ^ ]



问候,

AARIF SHAIKH
Please Refer this links:-

http://www.aspsnippets.com/Articles/HTML5-Show-Display-multiple-image-preview-before-upload-with-FileUpload-control-using-JavaScript-and-jQuery.aspx[^]

http://jqueryasp.net/upload-multiple-image-file-progress-bar-asp-net-using-jquery/[^]

http://www.c-sharpcorner.com/uploadfile/prathore/multiple-image-upload-in-Asp-Net/[^]

Regards,
AARIF SHAIKH


请参阅此链接可能对您有所帮助在WebForm中显示多个动态图像 [ ^ ]
Refer this link may be this could be helpful to you Displaying multiple dynamic images in a WebForm[^]


通过使用此解决方案,一旦页面被重新压缩,图像被删除



http://www.aspsnippets.com/Articles/HTML5-Show-Display-multiple-image-preview-before-upload-with-FileUpload-续rol-using-JavaScript-and-jQuery.aspx [^]



使用此解决方案,我无法显示解决方案。

http://jqueryasp.net/upload-multiple-image-file-progress-bar-asp-net-using-jquery/[^] ..



i有一个代码来上传图像,它成功保存到文件夹。 bt我不知道如何在aspx页面中显示这些图像。
by using this solution, once the the page refressed, the images get deleted

http://www.aspsnippets.com/Articles/HTML5-Show-Display-multiple-image-preview-before-upload-with-FileUpload-control-using-JavaScript-and-jQuery.aspx[^]

by using this solution, i cant able to display the solution.
http://jqueryasp.net/upload-multiple-image-file-progress-bar-asp-net-using-jquery/[^]..

i have a code to upload the images and it save successfully to the folder. bt i dont know how to display that images in aspx page.


这篇关于如何使用asp.net和c#动态上传和显示网页上的多个图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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