fileUpload does not load anything, does not throw errors

0

This file upload, does not load the file, does not throw an error, does nothing, just blink! and it was assumed that loaded, in the 4 labels that I put to verify the load does not throw anything either, it only appears:

Label Label Label Label

if (uplFilesComitePQR.HasFile)
        {
            try
            {
                int adjuntoPQRComite = lastIdenty;
                string fileExt = "";
                fileExt = Path.GetExtension(uplFilesComitePQR.FileName).ToLower();
                if (fileExt == ".doc" || fileExt == ".docx" || fileExt == ".pdf" || fileExt == ".xlsx")
                {
                    if (uplFilesComitePQR.PostedFile.ContentLength < 1500000)
                    {
                        string filename = Path.GetFileName(uplFilesComitePQR.FileName);
                        uplFilesComitePQR.SaveAs(Server.MapPath("~/uploads/PQR_adj/id_pqr_" + adjuntoPQRComite + fileExt));
                        Label1.Text = "Carga de archivo: Correcta!";
                    }
                    else
                        Label2.Text = "Carga de archivo: el archivo debe tener un tamaño inferior a 1.5mb!";
                }
                else
                    Label3.Text = "Carga de archivo: el tipo de archivo seleccionado no está permitido, por favor vuelva a intentarlo!";
            }
            catch (Exception ex)
            {
                Label4.Text = "Carga de archivo: el archivo no pudo ser cargado ha ocurrido el siguiete error: " + ex.Message;
            }
        }
    
asked by Vulpex 18.08.2017 в 15:47
source

1 answer

1

Well, after discovering that it is the debug and the point of interruption, the if (uplFilesComitePQR.HasFile) = false appeared, so reviewing how strange my code was was that the form is divided by 4 panels, and the fileupload is in panel 3 and the final send button in panel 4.

//.cs
     public void panelUno(object sender, EventArgs e)
        {
            this.pnlStepOne.Visible = true;
            this.pnlStepTwo.Visible = false;
            this.pnlStepThree.Visible = false;
            this.pnlStepFour.Visible = false;
        }
    public void panelDos(object sender, EventArgs e)
        {
            this.pnlStepOne.Visible = false;
            this.pnlStepTwo.Visible = true;
            this.pnlStepThree.Visible = false;
            this.pnlStepFour.Visible = false;
        }
    public void panelUno(object sender, EventArgs e)
        {
            this.pnlStepOne.Visible = false;
            this.pnlStepTwo.Visible = false;
            this.pnlStepThree.Visible = true;
            this.pnlStepFour.Visible = false;
        }
    public void panelUno(object sender, EventArgs e)
        {
            this.pnlStepOne.Visible = false;
            this.pnlStepTwo.Visible = false;
            this.pnlStepThree.Visible = false;
            this.pnlStepFour.Visible = true;
        }
//.aspx
    <asp:panel Id="pnlUno">(...)</asp:Panel>
    <asp:panel Id="pnlDos">(...)</asp:Panel>
    <asp:panel Id="pnlTre"><asp:FileUpload(...)></asp:Panel>
    <asp:panel Id="pnlCua">(...)</asp:Panel>

So what I did was to pass the fileupload to panel 4 and to attach the file only at the end when the user has checked that the survey of the previous panels is correct and thus avoid uploading the file in step 3 without the user has sent step 4. he left me the code like this:

//.aspx
    <asp:panel Id="pnlUno">(...)</asp:Panel>
    <asp:panel Id="pnlDos">(...)</asp:Panel>
    <asp:panel Id="pnlTre">(...)</asp:Panel>
    <asp:panel Id="pnlCua"><asp:FileUpload(...)></asp:Panel>
    
answered by 18.08.2017 / 16:59
source