public class Upload : IHttpHandler, IReadOnlySessionState
{
/// <summary>**********************************
/// ProcessRequest *
/// </summary>**********************************
public void ProcessRequest(HttpContext context)
{
string UploadPath = "InspectionImagesNew\\";
string strPathToSave = "BEFORE PATH IS APPLIED";
try
{
//context.Response.Write("HELLO");
HttpPostedFile fileToUpload = context.Request.Files["Filedata"];
//WORKS LOCALLY ON MY MACHINE***************************************************************************************************************
strPathToSave = HttpContext.Current.Server.MapPath("InspectionImagesNew//") + "TEMP_" + context.Session["VIN"].ToString() + "/" + fileToUpload.FileName;
//******************************************************************************************************************************************
//System.IO.File.WriteAllText(@"C:\test.txt", strPathToSave);
try
{
context.Session["ERROR_FROM_ASHX_CODE"] = strPathToSave;
fileToUpload.SaveAs(strPathToSave);
}
catch (Exception ex)
{
}
}
catch (Exception ex)
{
context.Response.ContentType = "text/plain";
context.Response.Write(ex.Message.ToString());
context.Session["ERROR_FROM_ASHX_CODE"] = ex.Message.ToString();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
$(document).ready(function () {
$("#<%=FileUpload1.ClientID %>").uploadify(
{
'swf': 'Scripts/uploadify.swf',
'uploader': 'Upload.ashx',
'auto': true,
'multi': true,
'buttonText': 'Select File(s)',
//'onQueueComplete': function (queueData) {
// alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
//}
'onQueueComplete': function (event, queueID, fileObj, response, data) {
$.ajax({
type: "POST",
url: "StockPhotos.aspx/CopyAndRename",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
//alert('This alert ensures onComplete is being called correctly');
//alert(response);
//alert(response.responseText);
},
'onUploadError': function (xhr, err) {
alert('responseText:' + xhr.responseText);
}
});
});
</script>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
This award recognizes an author who contributes the highest volume of original works or content. Recipients of this award produce extremely valuable content that prioritizes accuracy, relevancy, and professionalism.