Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[SOLVED] Progress bar behavior
  • Hi all,

    I'm trying to implement uploadify (thanks for a great tool!) on my ASP.NET (Umbraco) solution and so far it works - the files gets uploaded just as expected byt using a Generic Handler (.ashx)

    However, the progress bar is not working at all :( It doesn't start.. sometimes it does start (when selecting >1mb files) but then stops at around ~75%.

    Has anyone ever tried this and found a solution for it? I have tried to search both here on the forums and on google, but didn't find a working solution to the problem :/ My view looks like this:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileUpload.ascx.cs" Inherits="FileUpload" %>
    <link rel="stylesheet" href="/css/general.css" type="text/css" media="screen" />
    <link href="/Scripts/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="/Scripts/uploadify/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="/Scripts/uploadify/swfobject.js"></script>
    <script type="text/javascript" src="/Scripts/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
    <script type="text/javascript">
    // <![CDATA[
    var id = "55";
    var theString = "asdf";
    $(document).ready(function () {
    $('#fileInput').uploadify({
    'uploader': '/Scripts/uploadify/uploadify.swf',
    'script': 'UploadImagesHandler.ashx',
    'cancelImg': '/Scripts/uploadify/cancel.png',
    'auto': true,
    'multi': true,
    'fileDesc': 'Image Files',
    'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
    'queueSizeLimit': 90,
    'sizeLimit': 4000000,
    'buttonText': 'Vaelg billeder',
    'folder': '/uploads',
    'displayData': 'speed',
    'onAllComplete': function (event, data) { $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.'); }
    });
    });
    // ]]></script>
    <form runat="server">
    <input id="fileInput" name="fileInput" type="file" />
    </form>


    and my .ashx handler looks like this:


    public class UploadImagesHandler : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
    System.Collections.Generic.List<umbraco.cms.businesslogic.media.Media> images = new System.Collections.Generic.List<umbraco.cms.businesslogic.media.Media>();

    HttpPostedFile file = context.Request.Files["FileData"];

    umbraco.cms.businesslogic.media.Media m = umbraco.cms.businesslogic.media.Media.MakeNew(
    file.FileName, umbraco.cms.businesslogic.media.MediaType.GetByAlias("image"), umbraco.BusinessLogic.User.GetUser(0), 1212);



    string mediaRootPath = "d:/web/localuser/nuanceweb.dk/cms/media/";
    string storagePath = mediaRootPath + m.Id.ToString();
    System.IO.Directory.CreateDirectory(storagePath);
    string fullFilePath = storagePath + "\\" + file.FileName;

    file.SaveAs(fullFilePath);

    System.IO.FileStream fs = new System.IO.FileStream(fullFilePath,
    System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

    System.Drawing.Image image = System.Drawing.Image.FromStream(fs);

    fs.Close();

    System.Drawing.Bitmap bmp = System.Drawing.Bitmap.FromFile(fullFilePath) as System.Drawing.Bitmap;
    bmp = ResizeImage(bmp, 550, bmp.Height);
    bmp.Save(fullFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);

    int fileWidth;
    int fileHeight;

    fileWidth = bmp.Width;
    fileHeight = bmp.Height;

    bmp.Dispose();

    string ext = file.ContentType.Replace("image/", string.Empty);

    string fileNameThumb = fullFilePath.Replace("." + ext, "_thumb");
    generateThumbnail(image, 100, fileWidth, fileHeight, fullFilePath, ext, fileNameThumb + ".jpg");

    m.getProperty("umbracoExtension").Value = ext;
    m.getProperty("umbracoBytes").Value = file.ContentLength;
    m.getProperty("umbracoHeight").Value = fileHeight;
    m.getProperty("umbracoWidth").Value = fileWidth;

    string mediaPath = "/media/" + m.Id.ToString() + "/" + file.FileName;

    m.getProperty("umbracoFile").Value = mediaPath;
    m.XmlGenerate(new System.Xml.XmlDocument());
    }

    public bool IsReusable {
    get {
    return false;
    }
    }


    Any help/hint is greatly appreciated!

    Thanks in advance :)

    / Bo
  • Nevermind, I found the error myself ;) I needed to tell the flash file that everything went o.k by using:

    context.Response.Write("Success");

    In my ashx file!
  • The user and all related content has been deleted.