srs81 / CakePHP-AjaxMultiUpload

CakePHP 2 plugin to allow for easy multi-file upload with AJAX
Other
65 stars 33 forks source link

Only "Files" word #46

Closed Andres-Chandia closed 9 years ago

Andres-Chandia commented 10 years ago

Hi there, I have followed three times your instructions to implement the plugin but the result is always the same, I only get the word "Files" at the place of the form, I'm puting it at the index view: View/Terms/index.ctp, but I tried at the view.ctp file also and it happens the same. Just in case: cakephp/app/Plugin/AjaxMultiUpload# ls Config Console Controller Lib LICENSE Model README.md Test Vendor View webroot Add to bootstrap.php load => done Create file directory => done Add to controller => done Add to views => View/Terms/index.ctp => <?php echo $this->Upload->view('Term', $term['Term']['id']); ?>

thanks for your help

davidbonachera commented 10 years ago

I had something like this. And it came from the javascript insert in var str; of the edit function.

I modified the ready statement of the document with some jquery like this :

$(document).ready(createUploader());

By the way i extracted the html to put it inside an Elements view like this (upload_box.ctp):

<script src="<?=$webroot;?>/js/fileuploader.js" type="text/javascript"></script>

<div class="AjaxMultiUpload<?=$lastDir;?>" name="AjaxMultiUpload">
    <noscript>
         <p>Please enable JavaScript to use file uploader.</p>
    </noscript>
</div>
<script src="<?= $webroot;?>/js/fileuploader.js" type="text/javascript"></script>

<script>
    function createUploader(){
        var amuCollection = $(".AjaxMultiUpload<?=$lastDir;?>");
        for (var i = 0, max = amuCollection.length; i < max; i++) {
                action = amuCollection[i].className.replace('AjaxMultiUpload', '');
                window['uploader'+i] = new qq.FileUploader({
                    element: amuCollection[i],
                    action: '<?=$webroot;?>/uploads/upload/' + action + '/',
                    debug: true
                });
            }
        }
    $(document).ready(createUploader());    
</script>

And i called it like this in the edit function of UploadHelper.php

$str = $this->_View->element('AjaxMultiUpload.upload_box', array(
            'webroot' => $webroot,
            'lastDir' => $lastDir
        ));

        return $str;
srs81 commented 9 years ago

This should be fixed with the latest updates - the uploader now uses Dropzone.js rather than the older one, please check if its OK now.