.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

multifileupload

Posted By: kavitha     Posted Date: December 19, 2010    Points:2   Category :ASP.Net
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;
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 />";
}


Responses
Author: Narayanan             
Posted Date: October 24, 2011     Points: 20   

Hi,
refer this
http://forums.asp.net/t/1332463.aspx

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Ravi Ranjan Kumar             
Posted Date: October 29, 2011     Points: 20   

Firstupall you should format your code. because no one will be interested to read your while code without being it formated whatever you should mention what error you are getting.

I am going to suggest you to read this article. its awesome for lean how to Multiple File Upload With Progress Bar Using Flash and ASP.NET
http://www.codeproject.com/KB/aspnet/FlashUpload.aspx

Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend