Jump to content

Upload de imagem


999ANDRE999
Go to solution Solved by 999ANDRE999,

Recommended Posts

Olá pessoal,

Preciso de atualizar uma imagem num site através de upload. Uso o código abaixo para fazer isso:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class HR_Team : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (!Request.IsAuthenticated)//não autenticado
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!Page.IsPostBack)//autenticado
            {

            }
        }
    }

    protected void btnUpload_Click(object sender, EventArgs e)
    {

        if (FileUpload1.HasFile)
        {
            FileUpload1.SaveAs(Server.MapPath("~/images/rh/organigrama/" + FileUpload1.FileName));
            Image1.ImageUrl = "~/images/rh/organigrama/" + FileUpload1.FileName;
        }
    }
}

Quando carrego para fazer o upload aparece a imagem. O meu problema é que se sair da página e voltar a entrar a imagem desaparece.

Alguem me consegue ajudar?

Obrigado 🙂 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.