
Ayuda con codigo en fileupload y sqldatasource
Publicado por Edvin Enrique (3 intervenciones) el 26/11/2014 16:33:15
Saludos.
Quisiera saber si me podrian ayudar en este error que me da al ocupar fileupload y sqldatasource
este es el codigo que e ocupado:
podrian ayudarme.
gracias de antemano.



Quisiera saber si me podrian ayudar en este error que me da al ocupar fileupload y sqldatasource
este es el codigo que e ocupado:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class prueba : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
SaveFile(FileUpload1.PostedFile);
/*if ((FileUpload1.PostedFile.ContentType == "img/JPEG") ||
(FileUpload1.PostedFile.ContentType == "img/JPG") ||
(FileUpload1.PostedFile.ContentType == "img/PNG") ||
(FileUpload1.PostedFile.ContentType == "imag/GIF"))
{
}
else
StatusLbl.Text = "No se recone el archivo, tiene que ser JPEG, JPG, PNG, GIF";*/
}
else
StatusLbl.Text = "No se ha seleccionado un archivo";
}
void SaveFile(HttpPostedFile file)
{
string savePath = "C:\\Users\\admin\\Documents\\Visual Studio 2012\\WebSites\\Ingresar_Registros\\img\\";
string fileName = FileUpload1.FileName;
string pathToCheck = savePath + fileName;
string tempfileName = "";
if (System.IO.File.Exists(pathToCheck))
{
int counter = 2;
while (System.IO.File.Exists(pathToCheck))
{
tempfileName = counter.ToString() + fileName;
pathToCheck = savePath + tempfileName;
counter++;
}
fileName = tempfileName;
StatusLbl.Text = "El nombre del archivo ya existe." +
"<br />El nuevo nombre del archivo es: " + fileName;
}
else
{
StatusLbl.Text = "El archivo se subio exitosamente.";
}
savePath += fileName;
FileUpload1.SaveAs(savePath);
Prueba1Sds.Insert();
}
}
podrian ayudarme.
gracias de antemano.
- Ingresar_Registros.rar(2,4 MB)
Valora esta pregunta


0