I am using the following code to upload multiple files:
// Upload Source Code -HANDLER upload.ashx
<%@ WebHandler Language="C#" Class="Upload" %>
using System.Collections.Generic;//using System.Linq;using System;
using System.Web;using System.IO;using System.Collections;using System.Web.UI;
using System.Web.UI.WebControls;using System.Web.SessionState;
public class Upload : IHttpHandler, IRequiresSessionState{
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Expires = -1; try {
HttpContext.Current.Session["IsCompleted"] = false;
ArrayList ar = new ArrayList(100);
HttpPostedFile postedFile = context.Request.Files["Filedata"];
string savepath = "Uploads"; string tempPath = "";
tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
string sUserId = HttpContext.Current.Session["EmpID"].ToString();
savepath = context.Server.MapPath("../Payroll/" + tempPath + "/" + sUserId);
string filename = postedFile.FileName;
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
BinaryReader reader = new BinaryReader(postedFile.InputStream);
byte[] image = reader.ReadBytes(postedFile.ContentLength);
if (HttpContext.Current.Session["Images"] == null) {
ar.Insert(0, image);
HttpContext.Current.Session["Images"] = ar; }
else { ArrayList ar1 = new ArrayList(100);
ar1 = (ArrayList)HttpContext.Current.Session["Images"];
int count = ar1.Count; ar1.Insert(count, image);
HttpContext.Current.Session["Images"] = ar1; }
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; }
}}And in the AutoUpload.aspx<script type="text/javascript">
$(window).load( function() { var err=false;
$("#<%=FileUpload1.ClientID %>").uploadify ({
'uploader': 'scripts/uploadify.swf',
'cancelImg': 'images/cancel.png',
'buttonText': 'Select Files', 'script': 'Upload.ashx',
'folder': 'uploads', 'fileDesc': 'PDF Files',
'fileExt': '*.pdf', 'queueID' : 'fileQueue',
'sizeLimit' : 512 * 1024, 'queueSizeLimit' : '50',
'multi': true, 'auto': true,
'onSelect': function(a,b,c){
document.getElementById("imgLoading").className="show";
document.getElementById("lblWaitMessage").className="show"; },
'onQueueFull' : function(a,b){
alert("Only 50 Files Upload is Possible.");return false;},
'onError' : function (a, b, c, d) { err=true;
if (d.status == 404)
alert('Could not find upload script.');
else if (d.type == "HTTP")
alert('error '+d.type+": "+d.status);
else if (d.type =="File Size")
alert(c.name+' '+d.type+' Limit: '+Math.round(c.size/1024.0)+'KB');
else
alert('error '+d.type+": "+d.text);
}, 'onAllComplete': function(event, data) {
alert("Uploading Complete!" + '\n' + "Total uploaded: "+data.filesUploaded+ '\n' +" Total errors: "+data.errors);
window.parent.location.href = window.parent.location.href;
// alert("Uploading Complete! \\n Total uploaded: "+data.filesUploaded+" \\n Total errors: "+data.errors+" \\n Close this box to refresh the page and see your uploaded files.");
//refreshParent(); } }); });</script>
Please help..... when i am executing the above code in http it is working
while in https it is not working......