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.
UploadiFive 1.1.1 has been released which includes a small fix for added support on touch devices including iOS 6 devices.
Implentation with Zend
  • Okay,

    I have read, and tried a lot of things on how to implement uploadify with Zend, and I'm probably overlooking something, but I'm completely stuck. It seems my action isn't called.

    All the uploadify are placed in one directory inside the public folder.

    The upload button is called in a fancybox instance and is loaded from a hidden div on the same page (admin/images/index) through the inline concept of Fancybox.

    All the jquery stuff works great, the uploading works fine, and every file is completed. But the files aren't removed to the folder. When testing with the uploadify.php script everything works fine.

    There are no errors in the console.

    Tested on localhost
    Tested with Chrome 6.0.4 & Firefox 6.3.6
    Tested with uploadify 2.1

    This is my init code: (I use loader for the use of jquery scripts)
    // ImageUploader
    $('#uploaderImages').Loader({
    url: ['/dgpcms/public/uploadify/jquery.uploadify.v2.1.0.js', '/dgpcms/public/uploadify/swfobject.js', '/dgpcms/public/uploadify/uploadify.css'],
    //debug: [true],
    cache: [true],
    success: function(target){
    $(this).uploadify({
    'uploader' : '../../uploadify/uploadify.swf',
    'script' : '<?php echo $this->url(array(\'module\' => \'admin\', \'controller\' => \'images\', \'action\' => \'upload\')) ?>',
    'scriptData': {'PHPSESSID': '<?php echo session_id();?>'},
    'cancelImg' : '../../uploadify/cancel.png',
    'auto' : true,
    'folder' : '../../uploads/images/original/',
    'multi' : true,
    'sizeLimit' : '4194304',
    'queueSizeLimit' : 50,
    'buttonText': 'Select files',
    'fileDesc' : '',
    'fileExt' : '.jpg;*.jpeg;*.gif;*.png'
    });
    }
    });


    This is the code in my admin/images/upload
    public function uploadAction()
    {
    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $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;
    }
    }


    This is the code used in my bootstrap for the cookie problem:
    protected function _initSession()
    {
    $sessName = \"PHPSESSID\";
    $sessOptions = array('name' => $sessName);

    // Flash has problems with cookies so we pass the PHPSESSID variable via get
    // it'll be injected if it doesn't exist in _SERVER[\"HTTP_COOKIE\"] e.g. '; PHPSESSID=hdi5u83hfnu7ltlvp5q3bb53k4'
    if ((stripos($_SERVER['REQUEST_URI'], '__tkn') !== false)
    // &amp;amp;&amp;amp; preg_match('#^[a-z\d]{25,32}$#si', $_GET[$sessName])
    &amp;&amp; preg_match('#__tkn/([a-z\d]{25,32})#si', $_SERVER['REQUEST_URI'], $matches)
    &amp;&amp; (stripos($_SERVER[\"HTTP_COOKIE\"], $matches[1]) === false)) {
    $sid = $matches[1];

    $prefix = '';
    if (!empty($_SERVER[\"HTTP_COOKIE\"])) {
    $prefix = '; ';
    }

    $_SERVER[\"HTTP_COOKIE\"] .= $prefix . $sessName . '=' . $sid;
    $_COOKIE[$sessName] = $sid;

    Zend_Session::setId($sid);
    }

    Zend_Session::setOptions($sessOptions);
    }




    Anybody any clue? I'm completely lost....
  • What does the HTML look like at runtime for this line:

    'script'   : '<?php echo $this->url(array(\'module\' => \'admin\', \'controller\' => \'images\', \'action\' => \'upload\')) ?>',
  • I'm not entirely sure how to check that...

    I changed the url to the script in almost every way I could think of:

    ../../admin/images/upload
    <?php echo $this->baseUrl().'/admin/images/upload'; ?>
    <?php echo $this->baseUrl(); ?>/admin/images/upload
    http://localhost/dgpcms/public/admin/images/upload
  • Nobody has any idea?
  • Dudelisius said:
    I'm not entirely sure how to check that...

    http://localhost/dgpcms/public/admin/images/upload


    Load the page up in your browser and VIEW SOURCE...
    If I'm following what you're saying correctly, you've specified the 'script' parameter as 'http://localhost/dgpcms/public/admin/images/upload' ? If that's the case try providing a relative path to your document root. I'm assuming this is likely to be '/images/upload'?
  • The problem is still that I can't reach the controller action. I have changed some things for easier testing. The current code is as follows:

    ImagesController > indexAction
    public function indexAction()
    {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
    move_uploaded_file($tempFile,$targetFile);
    }


    index.phtml
    <script type=\"text/javascript\" src=\"<?php echo $this->baseUrl(); ?>/uploadify/jquery.uploadify.v2.1.0.min.js\"></script>
    <script type=\"text/javascript\" src=\"<?php echo $this->baseUrl(); ?>/uploadify/swfobject.js\"></script>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"<?php echo $this->baseUrl(); ?>/uploadify/uploadify.css\" />

    <script type=\"text/javascript\">// <![CDATA[
    $(document).ready(function() {
    $('#uploaderImages').uploadify({
    'uploader' : '../../uploadify/uploadify.swf',
    'script' : '<?php echo $this->url(array(\"controller\" => \"images\", \"action\" => \"index\")); ?>',
    'cancelImg' : '../../uploadify/cancel.png',
    'auto' : true,
    'scriptData' : {'PHPSESSID': '<?php echo session_id();?>'},
    'scriptAccess' : 'always',
    'queueID' : 'fileQueue',
    'folder' : '../../uploads/images/original/',
    'multi' : true
    });
    });
    // ]]></script>

    <a href=\"javascript:$('#uploaderImages').uploadifyClearQueue();\"><?php echo $this->translate('Clear Queue'); ?></a>
    <input type=\"file\" name=\"uploaderImages\" id=\"uploaderImages\" />
    <div id=\"fileQueue\"></div>


    And the source code looks like this:
    <script type=\"text/javascript\" src=\"/dgpcms/public/uploadify/jquery.uploadify.v2.1.0.min.js\"></script> 
    <script type=\"text/javascript\" src=\"/dgpcms/public/uploadify/swfobject.js\"></script>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"/dgpcms/public/uploadify/uploadify.css\" />

    <script type=\"text/javascript\">// <![CDATA[
    $(document).ready(function() {
    $('#uploaderImages').uploadify({
    'uploader' : '../../uploadify/uploadify.swf',
    'script' : '/dgpcms/public/admin/images/index',
    'cancelImg' : '../../uploadify/cancel.png',
    'auto' : true,
    'scriptData' : {'PHPSESSID': 'il0900fifd0l3nte1q30658094'},
    'scriptAccess' : 'always',
    'queueID' : 'fileQueue',
    'folder' : '../../uploads/images/original/',
    'multi' : true
    });
    });
    // ]]></script>


    I don't understand why the action isn't called..
  • I've been trying to do a similar thing, moving the uploadify.php into a controller action in CodeIgniter. When passing the full url to the controller action, its not working either. I know its posting the scriptData but is the actual file upload information going through a get request when its normally sent to uploadify.php?

    I have it working with CodeIgniter using a modified uploadify.php, but this is incredibly insecure because someone could make a http request to the uploadify file and even control which folder their file or even a php script uploads to, so it would be much more secure to move this into a controller action that gets posted to with the user and data checked.
  • Oke I fixed the whole thing. I discovered that the upload has to be added as a resource. There is no need to fix the session problem (at least, I didn't.

    Note: This is tested localhost only for now, I could be wrong on the session part!!

    This is how the scripts look:

    The index.phtml

    <script type=\"text/javascript\">// <![CDATA[
    $(document).ready(function() {
    $('#uploaderImages').uploadify({
    'uploader' : '../../uploadify/uploadify.swf',
    'script' : '<?php echo $this->baseUrl().'/admin/images/upload'; ?>',
    'cancelImg' : '../../uploadify/cancel.png',
    'scriptAccess' : 'always',
    'queueID' : 'fileQueue',
    'folder' : '../../uploads/images/original/',
    'multi' : true,
    'auto' : true,
    });
    });
    // ]]></script>


    The imageController:

    public function uploadAction()
    {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
    move_uploaded_file($tempFile,$targetFile);
    }


    And add the resource in your ACL:

    $this->acl->add(new Zend_Acl_Resource('upload'));


    If I encounter more problems, or if anybody else does, please let me now, and I will update this question/answer with needed additional info.

    Tested in Firefox 3.6 & Chrome 6.0
  • Added session solution as found here, encountered certain problems in firefox:

    viewtopic.php?f=5&t=43