uploading of images to server with minimun time

Posted by Chaithragm under C# on 3/7/2013 | Points: 10 | Views : 961 | Status : [Member] | Replies : 2
I have to do multiple upload of images (eg 5000 or more) to the server at once ..
can this be possible with a minimum of time ?

im using this code. but its taking more time ... for 400 images its taking 8-10 min...
is their any way to increase the performance??

protected void upload_btn_Click(object sender, EventArgs e)
{

Panel1.Visible = false;

try
{
fcount = 0;
totalcount = 0;
error_count = 0;
//Get the HttpFileCollection
System.Threading.Thread.Sleep(8000);
//byte[] imgbyte = null;
byte[] imgbyte = null;
HttpFileCollection hfc = Request.Files;
totalcount = hfc.Count;
writeToimage_LogFile();

for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile File = hfc[i];
imgbyte = new byte[File.ContentLength];
File.InputStream.Read(imgbyte, 0, (File.ContentLength));

DateTime date;
date = System.DateTime.Today;
filename = File.FileName;
int num;
num = search_duplicate(filename);
if (num == 2)
{

string image_name = File.FileName;
content_type=File.ContentType;

if (content_type != "application/pdf")
{
saveFolder = @"c:\v2docs\TempFiles";
filePath = Path.Combine(saveFolder, File.FileName);
File.SaveAs(filePath);
Convert_to_pdf();

save_to_server();
// delete_from_temp_file();

}

if (content_type == "application/pdf")
{

dataaccess2.imageUpload(imgbyte, image_name, content_type, date);
}
fcount += 1;

}
else
{

writeToimage_LogFile_error(filename);

}

Panel1.Visible = true;
}

string temp = string.Format("Upload Successfull...! {0}/{1} New Image(s) Uploaded.", fcount, totalcount);
writeToLogFile_status(temp);
string msg = string.Format("Upload Successfull...! {0}/{1} New Image(s) Uploaded.", fcount, totalcount);
HyperLink hplnk = new HyperLink();
hplnk.Text = "View Log";

hplnk.NavigateUrl = "ImageLogView.aspx";

string logmsg = "For more information";
hplnk.Target = "_blank";
log_lbl.Text = logmsg;
PlaceHolder1.Controls.Add(hplnk);
Label1.Text = msg;



}


catch
{
string msg1 = ("Image size is too large ");
Label2.Text = msg1;

}


}




Responses

Posted by: Rimi1289 on: 3/7/2013 [Member] Starter | Points: 25

Up
0
Down
It depends on the internet speed. There is nothing much we can do about it. You should try some 3rd party tools to do this job.

Chaithragm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepmhatre on: 3/23/2013 [Member] Starter | Points: 25

Up
0
Down
hope this link will help you

http://sandeepmhatre.blogspot.in/2012/12/dynamic-file-upload-in-dynamic-gridview_16.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Chaithragm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response