hi friends,
this code is multifileupload using jquery .
that code store file/images is image folder.
but i want to store file/images in database.
so please correct this code.
thanks.
protected void jQueryUploadFiles(object sender, EventArgs e)
{
FileUploadUsingJQuerySelectionMethod();
}
/// <summary>
/// file upload file using ASP.NET FileUpload control
/// </summary>
/// <param name="fileUpload"></param>
private void UploadFileUsingASPNET(FileUpload fileUpload)
{
try
{
// check if file has been selected
if (fileUpload.HasFile)
{
string path = Server.MapPath("~/MultipFileUpload/");
string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);
// check for the valid file extension
string fileExtension = Path.GetExtension(fileName).ToLower();
if (fileExtension.Equals(".gif") || fileExtension.Equals(".jpg"))
{
// now save the file to the disk
fileUpload.SaveAs(path + fileName);
lblMessage.Text += "File : <b>" + fileName + "</b> uploaded successfully ! <br />";
}
else
{
lblError.Text = "Only .gif and .jpg files are allowed.";
}
}
else
{
lblError.Text = "Please select a valid file.";
}
}
catch (Exception ee)
{
lblError.Text = ee.Message;
}
}
/// <summary>
/// file upload using jQuery file selection mechanism
/// </summary>
private void FileUploadUsingJQuerySelectionMethod()
{
// check if file has been selected
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (file.ContentLength > 0)
{
string path = Server.MapPath("~/MultipFileUpload/");
string fileName = Path.GetFileName(file.FileName);
// now save the file to the disk
file.SaveAs(path + fileName);
lblMessage.Text += "File : <b>" + fileName + "</b> uploaded successfully !<br />";
}
}