Hi,
These article said to posses
1) A file uploader
Which is used for uploading files to server
2)A grid view
Whic is used to store the uploaded file to te user and to delete it.
step1: Place a uploader in design page and write a coding as
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
fname = FileUpload1.FileName;
spath = @"~\ssg\" + FileUpload1.FileName;
fpath = Server.MapPath("ssg");
fpath = fpath + @"\" + FileUpload1.FileName;
desc = TextBox2.Text;
if (System.IO.File.Exists(fpath))
{
Label1.Text = "File Name already exists!";
return;
}
else
{
FileUpload1.SaveAs(fpath);
}
//Store details in the SQL Server table
StoreDetails();
TextBox2.Text = "";
//Refresh grid
LoadGrid();
}
else
{
Label1.Text="Please select file!";
}
}
step 2: Now for loading grid and storing details write coding as
void LoadGrid()
{
sqlcon.Open();
sqlcmd = new SqlCommand("select * from fileDet", sqlcon);
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
GridView1.DataBind();
}
sqlcon.Close();
}
Main concept behind this isDuring uploaded time i have store the server path in the SQL Server.
I had bind server path in Grid View Hyper link (Navigate URL).
Then bind in grid view If user click the file name in the grid view then files are downloaded.
NOTE: Create the folder named ssg in your application
Please find attachment for more details...