Re: Ajax Uploader in MVC deletres ALL pages from History

  •  05-11-2010, 5:19 AM

    Re: Ajax Uploader in MVC deletres ALL pages from History

    We also tried it in FireFox with 1 image (i.e. 1 uploader) and it seems to work. But when you put a few uploaders on the page, that seems to be the problem.
     
    The way we are putting several (infact 10) uploaders on the page is
     
    First Uploader

    using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))

    {

    uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");

    //the data of the uploader will render as <input type='hidden' name='myuploader'>

    uploader.FormName = "uploader1";

    uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp";

    uploader.InsertButtonID = "image1";

    //uploader.UploadType = CuteWebUI.UploadType.Flash;

    //prepair html code for the view

    ViewData["uploaderhtml1"] = uploader.Render();

    //if it's HTTP POST:

    if (!string.IsNullOrEmpty(uploadervalue) && uploaderid == "uploader1")

    {

    //for single file , the value is guid string

    Guid fileguid = new Guid(uploadervalue);

    CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);

    if (file != null)

    {

    //you should validate it here:

    //now the file is in temporary directory, you need move it to target location

    //file.CopyTo("~/TempDir/" + file.FileName);

    //ResizeImage(file, uploaderid);

    //set the output message

    ViewData["UploadedMessage"] = "The file " + file.FileName + " has been processed.";

    }

    }

    }

    //

     
    Second Uploader and so on

     

    using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))

    {

    uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");

    //the data of the uploader will render as <input type='hidden' name='myuploader'>

    uploader.FormName = "uploader2";

    uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp";

    uploader.InsertButtonID = "image2";

    //uploader.UploadType = CuteWebUI.UploadType.Flash;

    //prepair html code for the view

    ViewData["uploaderhtml2"] = uploader.Render();

    //if it's HTTP POST:

    if (!string.IsNullOrEmpty(uploadervalue) && uploaderid == "uploader2")

    {

    //for single file , the value is guid string

    Guid fileguid = new Guid(uploadervalue);

    CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);

    if (file != null)

    {

    //you should validate it here:

    //now the file is in temporary directory, you need move it to target location

    //file.CopyTo("~/TempDir/" + file.FileName);

    //ResizeImage(file, uploaderid);

    //set the output message

    ViewData["UploadedMessage"] = "The file " + file.FileName + " has been processed.";

    }

    }

    }

View Complete Thread