Sorry... I can't deal with all the SPAM so until I can find a better solution for the forums, I'm locking them down. For now please use awesome services like stackoverflow.com for community support. Thanks.
This forum is a community forum meant for users of the plugin to collaborate and help solve issues with implementation, etc. Unfortunately, as the creator of the plugin, I do not have much time to attend to every request here as this is only a side project and I must work a full-time job to provide for my family. This is how I keep the Flash version free and the HTML5 version low cost.
Zend Framework Integration Help
  • I am trying to integrate the Uploadify with Zend Framework/JQuery but I simply cannot get it right.

    I have posted detailed description of how I'm going about it at stackoverflow: http://stackoverflow.com/questions/1338 ... r-troubles

    Please somebody experienced take a look and help me because I've been trying to get it work for hours now.
  • Couple things to check:

    If you're doing any .htaccess file extension filtering make sure you are including swf in your white list

    RewriteRule !\.(js|ico|gif|jpg|png|css|txt|swf)$ index.php


    Try using an absolute URL for the flash file

    $(document).ready(function() {
    $(\"#photo\").uploadify({
    'uploader' : '<?php echo $this->baseUrl('/flash-uploader/scripts/uploadify.swf') ?>',
    'script' : 'my-account/flash-upload',
    'cancelImg' : '/flash-uploader/cancel.png',
    'folder' : 'uploads/tmp',
    'queueID' : 'fileQueue',
    'auto' : true,
    'multi' : true,
    'sizeLimit' : 2097152
    });
    });

  • Thanks for help. I managed to solve the issue by playing with the order of tags in the head section. Now the 'browse' button appears but I have another problem.

    It seems like there is a problem with this line:

    'script'         : 'my-account/flash-upload',


    Because I get a progressbar and it says upload completed but the code in the flash-upload action in the my-account controller doesn't get executed. I tried also:

    'script'         : '/my-account/flash-upload',


    And also absolute path:

    'script'         : 'http://mywebsite.com/my-account/flash-upload',


    None of them works :(
  • I also tried rewriting the URL so it ends with '.php', with no success.
  • I am about to try Uploadify with ZF. But I think the issue you are running into is simply due to Zend's naming conventions. URL's are named as controller/action and their naming rules do not allow hypens in the controller name or action names.

    Try:
        'script'         : 'myaccount/flashupload',


    This would mean the Zend request would be routed to
     
    controller: MyaccountController
    action: flashuploadAction
  • That is incorrect.

    You are right that hyphens are not allowed in controllers' and actions' names. However, this:

    MyAccountController


    Is translated to:

    my-account


    in the URL.

    I know this for sure, I've been using ZF for almost a year now.
  • risoknop said:
    Thanks for help. I managed to solve the issue by playing with the order of tags in the head section. Now the 'browse' button appears but I have another problem.

    It seems like there is a problem with this line:

    'script'         : 'my-account/flash-upload',


    Because I get a progressbar and it says upload completed but the code in the flash-upload action in the my-account controller doesn't get executed. I tried also:

    'script'         : '/my-account/flash-upload',


    And also absolute path:

    'script'         : 'http://mywebsite.com/my-account/flash-upload',


    None of them works :(


    Don't fear risoknop, I've been banging my head on the keyboard for two days now but was finally able to get this to work last night. Here is what I'm doing for my script parameter:

    'script' : '<?php echo $this->url(array('controller' => 'upload', 'action' => 'handle-file-upload')) ?>',


    UploadController.php | public function handleFileUploadAction()
    Just to note: I'm using an application specific protected method to determine the absolute path on the server to store the files at.

    public function handleFileUploadAction()
    {
    $this->disableAutoRendering();

    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $this->_getFileUploadPathForUser($_POST['userID']) . '/'; // app specific function
    $targetFile = str_replace('//', '/', $targetPath) . $_FILES['Filedata']['name'];

    // If the target directory isn't available, create it
    if (!is_dir($targetPath)) {
    mkdir($targetPath, 02775, true);
    }

    move_uploaded_file($tempFile, $targetFile);

    switch ($_FILES['Filedata']['error'])
    {
    case 0:
    $msg = \"No Error\"; // comment this out if you don't want a message to appear on success.
    break;
    case 1:
    $msg = \"The file is bigger than this PHP installation allows\";
    break;
    case 2:
    $msg = \"The file is bigger than this form allows\";
    break;
    case 3:
    $msg = \"Only part of the file was uploaded\";
    break;
    case 4:
    $msg = \"No file was uploaded\";
    break;
    case 6:
    $msg = \"Missing a temporary folder\";
    break;
    case 7:
    $msg = \"Failed to write file to disk\";
    break;
    case 8:
    $msg = \"File upload stopped by extension\";
    break;
    default:
    $msg = \"unknown error \".$_FILES['Filedata']['error'];
    break;
    }

    if ($msg) {
    $stringData = \"Error: \".$_FILES['Filedata']['error'].\" Error Info: \".$msg;
    } else {
    $stringData = \"1\"; // This is required for onComplete to fire on Mac OSX
    }

    echo $stringData;
    }
    }


    If you're using session based authentication the uploads will appear to complete, no errors, but the files will not get moved and your script will not get called. I was in a similar situation using checks to automatically route traffic to the sign in page if they were found to not be authenticated. Try adding the onComplete function to the javascript parameter list and output the response. Chances are you'll be getting back the HTML for your sign-in page as well.


    onComplete(event, queueID, fileObj, response, data) {
    alert('Response: ' + response);
    }


    If that is the case you could try something similar to my solution posted here.

    Hope this helps :)