virafh
asked on
uploading multiple image
Dear Experts,
I am uploading multimple file with flash uploader but i am not able to collect all images name in list.
Plesae check my coed and tell me where i am wrong.
i have one if condition in my code and i am making a session and checking session is not null if its not null my if condition should fire and list can increase till my images not get uploaded.
I am uploading multimple file with flash uploader but i am not able to collect all images name in list.
Plesae check my coed and tell me where i am wrong.
i have one if condition in my code and i am making a session and checking session is not null if its not null my if condition should fire and list can increase till my images not get uploaded.
<script type="text/javascript">
$(window).load(
function() {
$("#<%=FileUpload1.ClientID %>").fileUpload({
'uploader': '../Scripts/uploader.swf',
'cancelImg': '../images/cancel.png',
'buttonText': 'Browse Files',
'script': '../Upload.ashx',
'folder': '../uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'multi': true,
'auto': true
});
}
);
</script>
//i am using the above script to call below code
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
using OnlineSystems;
using System.Collections.Generic;
using System.Web.SessionState;
public class Upload : IHttpHandler, IRequiresSessionState, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Expires = -1;
try
{
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "";
string tempPath = "";
tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
savepath = context.Server.MapPath(tempPath);
string filename = DateTime.Now.ToString("ddMMyymmss") + postedFile.FileName.Replace(' ', '_');
blEventImage obj = new blEventImage();
obj.title = filename.ToString();
//if condition not working each time its goin in else
if (HttpContext.Current.Session["Imgs1"] != null)
{
List<blEventImage> lst = new List<blEventImage>();
lst = (List<blEventImage>)HttpContext.Current.Session["Imgs1"];
lst.Add(obj);
HttpContext.Current.Session["Imgs1"] = lst;
}
else
{
List<blEventImage> lst = new List<blEventImage>();
lst.Add(obj);
HttpContext.Current.Session["Imgs1"] = lst;
}
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
postedFile.SaveAs(savepath + @"\" + filename);
context.Response.Write(tempPath + "/" + filename);
context.Response.StatusCode = 200;
}
catch (Exception ex)
{
context.Response.Write("Error: " + ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.c-sharpcorner.com/UploadFile/prathore/MultipleImagesUpload05122009042335AM/MultipleImagesUpload.aspx
ASKER
please help me with my given code i dont have much time to see the others example.
i have done all the codings parts and its working fine multiple images are uploading in given folder.
i am facing a problem when i am collecting all the images in list.
first image coming in list properly then i am storing list in session and on the second image i am checking if session not null then list.count == 2 same on the 3rd image list.count = 3 but every time it shows session null because of that each and every time list.count shows 1 only i want to take all the images name in session
please help me with this.
Thanks in advance
i have done all the codings parts and its working fine multiple images are uploading in given folder.
i am facing a problem when i am collecting all the images in list.
first image coming in list properly then i am storing list in session and on the second image i am checking if session not null then list.count == 2 same on the 3rd image list.count = 3 but every time it shows session null because of that each and every time list.count shows 1 only i want to take all the images name in session
please help me with this.
Thanks in advance
ASKER
please comment on my question i am waiting for ur response its urgent
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok i will check and get back to u
ok.. sure..
ASKER
thank you