简体   繁体   中英

Image browse/upload with KCfinder to own folder in yii

I am using KCFinder 3.0 in a yii website. I have many users so i have to separata the uploaded images so i need to open own folder when the writers want to browse an image from server. How can i do this? I have this code

    CKEDITOR.replace( 'editor1', {
       filebrowserBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=files',
       filebrowserImageBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=image',
       filebrowserFlashBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=flash',
       filebrowserUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=files',
       filebrowserImageUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=images',
       filebrowserFlashUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=flash'   });

If I add the get parameter it is ignored and just browses and uploads to a directory called "files".

        CKEDITOR.replace( 'editor1', {
           filebrowserBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=2014_10_12',
           filebrowserImageBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=2014_10_12',
           filebrowserFlashBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=2014_10_12',
           filebrowserUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=2014_10_12',
           filebrowserImageUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=2014_10_12',
           filebrowserFlashUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=2014_10_12'
  }); 

If the javascript code you've written is in a .js file, the PHP code you've embedded into it will not be parsed .

PHP code only gets parsed if it's a .php file.

If, on the other hand, you use Yii's registerScript method, you can add Javscript code from a PHP file (although you shouldn't do too much of it or your code will be a mess).

For example (on a Yii view file ):

<?php
  $this->breadcrumbs = [
    'Foo',
    'Bar'
  ];
?>

<?php Yii::app()->getClientScript()->registerScript('
    $(document).ready(function{
        console.log("yay");
    }); 
'); ?>
<br />
<br />
<div class="post">
<!-- the rest of your view file.... -->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM