Re: Button to select files for uploading unavailable in IE

  •  07-19-2012, 8:02 AM

    Re: Button to select files for uploading unavailable in IE

    Hi.
    I'm also experiencing this same issue with IE when I've deployed the web application to the web server. The weird think is that it's running ok in my development machine, and it also works fine in both machines, the development one and the server, with Opera, Firefox and Safari, but accessing using IE to the application deployed in the web server, the button simply doesn't fire the files selection dialog.
     
    I've downloaded the version from http://www.cutesoft.net/downloads/folders/44395/download.aspx so it seems that here isn't the solution. I've written an example that you can run in my web server with this url: http://peritaciones.tandemcr.com/pruajaxuploader/default.aspx. And below you can find the code.
     
    Thank you in advance
    Juan Miguel
     
    First the aspx file:

    <%@ Page Title="Página principal" Language="C#" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="PruebaAjaxUploader._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <asp:Button ID="btnPostBack" runat="server" Text="Post back" /> 
            <asp:Label ID="label1" runat="server"></asp:Label>
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:UpdateProgress ID="upgrPeritacion" AssociatedUpdatePanelID="updtPeritacion" runat="server">
                <ProgressTemplate>
                    <div class="upgProgreso">
                        <div class="textoProgreso"><span id="upgrPeritacionText">Loading...</span></div>
                        <div class="imagenProgreso"><img alt="Espere un momento, por favor" src="img/cargando.gif" /></div>
                    </div>     
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:UpdatePanel ID="updtPeritacion" runat="server">
                <ContentTemplate>
                    <h2>
                        Testing Ajax Uploader
                    </h2>

                    <fieldset>
                        <legend>Documentation</legend>
                            <CuteWebUI:UploadAttachments ID="uaDocumentos"
                                runat="server"
                                OnUploadCompleted="uaDocumentos_UploadCompleted">
                            </CuteWebUI:UploadAttachments>
                            <fieldset>
                                <legend>Photographs</legend>
                                <asp:Repeater ID="rptFotos" runat="server" onitemcommand="rptFotos_ItemCommand"
                                    onitemdatabound="rptFotos_ItemDataBound">
                                    <ItemTemplate>
                                        <div style="float:left; padding-left:5px; padding-right:5px;">
                                            <div>
                                                <asp:LinkButton ID="lnkBorrar" CssClass="BorrarFoto" runat="server" CommandName="Borrar" >X Delete</asp:LinkButton>
                                            </div>
                                            <div>
                                                <a href="<%# DataBinder.Eval(Container.DataItem, "url") %>" target="_blank">
                                                    <img src="<%# DataBinder.Eval(Container.DataItem, "url") %>" alt="<%# DataBinder.Eval(Container.DataItem, "nombreFichero") %>" style="height:100px;"/>
                                                </a>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </fieldset>
                            <fieldset>
                                <legend>Other Documents</legend>
                                <asp:Repeater ID="rptOtrosDoc" runat="server" onitemcommand="rptFotos_ItemCommand"
                                    onitemdatabound="rptOtrosDoc_ItemDataBound">
                                    <ItemTemplate>
                                        <div style="float:left; padding-left:5px; padding-right:5px;">
                                            <div>
                                                <asp:LinkButton ID="lnkBorrar" CssClass="BorrarFoto" runat="server" CommandName="Borrar">X Delete</asp:LinkButton>
                                            </div>
                                            <div>
                                                <a href="<%# DataBinder.Eval(Container.DataItem, "url") %>" target="_blank">
                                                    <asp:Image ID="imgTipoDoc" runat="server" />
                                                    <br /><%# DataBinder.Eval(Container.DataItem, "nombreFichero") %>
                                                </a>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </fieldset>
                    </fieldset>
                    <fieldset>
                        <legend>Report</legend>
                        <div id="divSelecPdfInforme" runat="server" class = "etiquetaGrupo">
                            <CuteWebUI:UploadAttachments ID="uaPdfInforme"
                                runat="server"
                                MultipleFilesUpload="False"
                                MaxFilesLimit="1"
                                DialogFilter="*.pdf"
                                ValidateOption-AllowedFileExtensions="pdf"
                                ShowCheckBoxes="False"
                                ShowRemoveButtons="False"
                                OnUploadCompleted="uaPdfInforme_UploadCompleted" >
                            </CuteWebUI:UploadAttachments>
                        </div>
                        <div id="divPdfInforme" runat="server" class="valorGrupo">
                            <asp:Label ID="Label2" runat="server" Text="Pdf Report:"></asp:Label>
                            <asp:HyperLink ID="hlkPdfInforme" Target="_blank" runat="server">View Report</asp:HyperLink>
                            &nbsp;
                            <asp:Button ID="btnBorrarPdfInforme" runat="server" CssClass="boton" onclick="btnBorrarPdfInforme_Click" Text="Delete Report"></asp:Button>
                        </div>
                    </fieldset>
                </ContentTemplate>
                <Triggers>
                </Triggers>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>

     And then the cs code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using System.Data;
    using System.IO;
    using CuteWebUI;

    namespace PruebaAjaxUploader
    {
        public partial class _Default : System.Web.UI.Page
        {
            #region Propiedades
            #region PathCarpetaServicio
            private String PathCarpetaServicio
            {
                get { return "test"; }
            }
            #endregion

            #region PathPdfInforme
            public string PathPdfInforme
            {
                get { return this.PathCarpetaServicio + "/Report.pdf"; }
            }
            #endregion
            #endregion

            #region Rutinas controladoras de eventos
            #region Page_Load
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    label1.Text = "first load!";
                    hlkPdfInforme.NavigateUrl = this.PathPdfInforme;
                    if (!Directory.Exists(Server.MapPath(this.PathCarpetaServicio)))
                        Directory.CreateDirectory(Server.MapPath(this.PathCarpetaServicio));
                    else
                    {
                        CargarDocumentacion();
                        if (File.Exists(Server.MapPath(this.PathPdfInforme)))
                        {
                            divPdfInforme.Style["display"] = "inline";
                            divSelecPdfInforme.Style["display"] = "none";
                        }
                        else
                        {
                            divPdfInforme.Style["display"] = "none";
                            divSelecPdfInforme.Style["display"] = "inline";
                        }
                    }
                }
                else
                    label1.Text = "post back!"; 
            }
            #endregion

            #region rptFotos_ItemDataBound
            protected void rptFotos_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                DataRowView dr = e.Item.DataItem as DataRowView;
                //Image img = e.Item.FindControl("imgFoto") as Image;
                //img.ImageUrl = dr["url"].ToString();
                LinkButton lnkb = e.Item.FindControl("lnkBorrar") as LinkButton;
                lnkb.CommandArgument = dr["nombreFichero"].ToString();
            }
            #endregion

            #region rptOtrosDoc_ItemDataBound
            protected void rptOtrosDoc_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                DataRowView dr = e.Item.DataItem as DataRowView;
                //Label lblNombreFichero = e.Item.FindControl("lblNombreFichero") as Label;
                //lblNombreFichero.Text = dr["nombreFichero"].ToString();
                Image imgTipoDoc = e.Item.FindControl("imgTipoDoc") as Image;
                String srvPathImagen = Path.Combine(Server.MapPath("img"), String.Format("{0}.png", dr["extension"]));
                if (File.Exists(srvPathImagen))
                    imgTipoDoc.ImageUrl = String.Format("img/{0}.png", dr["extension"]);
                else
                    imgTipoDoc.ImageUrl = "img/archivo.png";
                LinkButton lnkb = e.Item.FindControl("lnkBorrar") as LinkButton;
                lnkb.CommandArgument = dr["nombreFichero"].ToString();
            }
            #endregion

            #region rptFotos_ItemCommand
            protected void rptFotos_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                String NombreFichero = Path.Combine(Server.MapPath(this.PathCarpetaServicio), e.CommandArgument.ToString());
                if (File.Exists(NombreFichero))
                {
                    File.Delete(NombreFichero);
                    CargarDocumentacion();
                }
            }
            #endregion

            #region uaDocumentos_UploadCompleted
            protected void uaDocumentos_UploadCompleted(object sender, UploaderEventArgs[] args)
            {
                foreach (AttachmentItem item in uaDocumentos.Items)
                {
                    String srvNombreFichero = item.FileName;
                    item.CopyTo(Path.Combine(Server.MapPath(this.PathCarpetaServicio), srvNombreFichero));
                }

                uaDocumentos.DeleteAllAttachments();
                CargarDocumentacion();
            }
            #endregion

            #region uaPdfInforme_UploadCompleted
            protected void uaPdfInforme_UploadCompleted(object sender, CuteWebUI.UploaderEventArgs[] args)
            {
                if (uaPdfInforme.Items.Count > 0)
                {
                    uaPdfInforme.Items[0].CopyTo(Server.MapPath(this.PathPdfInforme));
                    divSelecPdfInforme.Style["display"] = "none";
                    divPdfInforme.Style["display"] = "inline";
                }
                uaPdfInforme.DeleteAllAttachments();
            }
            #endregion

            #region btnBorrarPdfInforme_Click
            protected void btnBorrarPdfInforme_Click(object sender, EventArgs e)
            {
                if (File.Exists(Server.MapPath(this.PathPdfInforme)))
                    File.Delete(Server.MapPath(this.PathPdfInforme));

                divSelecPdfInforme.Style["display"] = "inline";
                divPdfInforme.Style["display"] = "none";

            }
            #endregion
            #endregion

            #region Rutinas internas
            #region CargarDocumentacion
            private void CargarDocumentacion()
            {
                DataTable dtFotos = new DataTable();
                dtFotos.Columns.AddRange(new DataColumn[] { new DataColumn("url", typeof(String)), new DataColumn("nombreFichero", typeof(String)) });
                DataTable dtDocumentos = new DataTable();
                dtDocumentos.Columns.AddRange(new DataColumn[] { new DataColumn("url", typeof(String)), new DataColumn("nombreFichero", typeof(String)), new DataColumn("extension", typeof(String)) });

                String[] srvFicheros = Directory.GetFiles(Server.MapPath(this.PathCarpetaServicio));
                foreach (String f in srvFicheros)
                {
                    string srvExtension = Path.GetExtension(f).ToLower().Substring(1);
                    if (srvExtension == "jpg" || srvExtension == "gif" || srvExtension == "bmp" || srvExtension == "png")
                        dtFotos.Rows.Add(new Object[] { String.Format("{0}/{1}", this.PathCarpetaServicio, Path.GetFileName(f)), Path.GetFileName(f) });
                    else
                    {
                        dtDocumentos.Rows.Add(new Object[] { String.Format("{0}/{1}", this.PathCarpetaServicio, Path.GetFileName(f)), Path.GetFileName(f), srvExtension });
                    }
                }

                rptFotos.DataSource = dtFotos;
                rptFotos.DataBind();
               
                rptOtrosDoc.DataSource = dtDocumentos;
                rptOtrosDoc.DataBind();
            }
            #endregion
            #endregion
        }
    }

View Complete Thread