Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

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.
<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;
        }
    }
}

Open in new window

0
virafh
Asked:
virafh
  • 4
  • 2
  • 2
2 Solutions
 
virafhAuthor Commented:
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
virafhAuthor Commented:
please comment on my question i am waiting for ur response its urgent
0
 
Rajeshk_cgmCommented:
hope you are using Flash Upload..
Try this below link example...
http://www.codeproject.com/KB/aspnet/FlashUpload.aspx

and add the below line in your web.config within <system.web> Tag
<httpRuntime maxRequestLength="2097151" executionTimeout="700"/>
0
 
virafhAuthor Commented:
ok i will check and get back to u
0
 
Rajeshk_cgmCommented:
ok.. sure..
0
 
virafhAuthor Commented:
thank you
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now