My function that saves the images in the folder works correctly, but when I open the folder of the photos the images appear duplicate but with different names Here's the save function:
protected void btnSalvarImovel_Click(object sender, EventArgs e)
{
if (fuFotos.HasFile == false)
lblImovel.Text = "Por favor selecione uma foto!";
else
{
List<string> nomeFoto = new List<string> ();
var arquivos = fuFotos.PostedFiles;
foreach (var arquivo in arquivos)
{
string nomeArquivo = arquivo.FileName;
fuFotos.PostedFile.SaveAs(Server.MapPath("~") + "/Imovel/" + nomeArquivo);
nomeFoto.Add("~/Imovel/" + nomeFoto + nomeArquivo + arquivo.FileName);
}
string comandoSQL = string.Format("INSERT INTO Imovel Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
ddlCidade.SelectedItem.Value, ddlLocalizacao.SelectedItem.Value, ddlOperacao.SelectedItem.Value, ddlTipoImovel.SelectedItem.Value,
txtTitulo.Text, txtObservacao.Text, txtValor.Text, txtQtdQuartos.Text, string.Join(",", nomeFoto));
lblImovel.Text = "Imóvel cadastrado com sucesso!";
ddlCidade.Text = string.Empty;
ddlLocalizacao.Text = string.Empty;
ddlOperacao.Text = string.Empty;
ddlTipoImovel.Text = string.Empty;
txtTitulo.Text = string.Empty;
txtObservacao.Text = string.Empty;
txtValor.Text = string.Empty;
txtQtdQuartos.Text = string.Empty;
try
{
conexaoSQL.Open();
int teste = new SqlCommand(comandoSQL, conexaoSQL).ExecuteNonQuery();
}
finally
{
conexaoSQL.Close();
}
}
}
The folder photo:
Beingthatitshouldhavelookedlikethis:
Inoticedthatthebankisbeingsavedlikethis:
Is there anything to see? Would anyone know what might be causing this or how to help me make it? Thanks in advance.