troubleshooting Question

Do you have to write custom php with uploadify?

Avatar of Michael Sterling
Michael SterlingFlag for United States of America asked on
JavaScriptC#AJAX.NET Programming
4 Comments1 Solution150 ViewsLast Modified:
I'm using uploadify and on my local machine the uploading works fine, but when I push my application out to our development server, the files don't get uploaded at all even though I get the message saying that the upload has completed / was successful. It also restarts my application and kicks me out to my login page. In my research I see examples of people who have had a similar problem, but in those cases they are using custom .php code which I was not under the impression that I needed to do that especially since it works fine on my local machine with out it. Thought? Links?

my IHttpHandler class
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;
            }
        }
    }

my jQuery
        $(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>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”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.

-Mike Kapnisakis, Warner Bros