Closed saidbakr closed 8 years ago
fixed on https://github.com/navatech/yii2-roxymce/commit/f4f73abdbc31d1123503b1f092c5f28d59d29e9f
please use @dev
version in composer
"navatech/yii2-roxymce" : "@dev"
thanks
I, already, have it "navatech/yii2-roxymce": "@dev"
as you said. In addition, setting FILE_ROOT
to dirname(__DIR__).DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.'images'
does not change any thing it is deals with directory c:\images
By the way, I'm using Yii2 Basic app.
I found partial solution. As regarded above my server works on Windows. I tried the following:
'FILES_ROOT' => 'xampp\\htdocs\\yii2app\\web\\images'
It works and it pointed to the correct folder and all images there are loaded. However, there is little issue with the integration with ckEditor. the inserted image URL is pointing to missing path to the server, i.e xampp/htdocs/yii2app/web/images/photo1.png
It should be /images/photo1.png
.
@saidbakr you just simple define:
'FILES_ROOT' => 'images'
if you want store in DOCUMENT_ROOT/yii2app/web/images
by default, FILES_ROOT
has prefix
Yii::getAlias('@app/web');
if yii2-basic
Yii::getAlias('@app/frontend');
if yii2-advanced
'FILES_ROOT' => 'uploads/image' //default
That means echo FILES_ROOT
will return:
Yii::getAlias('@app/web/uploads/image');
//On windows: X:\xampp\htdocs\your_app\web\uploads\image
//On linux: /var/www/html/your_app/web/uploads/image
I'd like to confirm that setting FILES_ROOT
as images
leads to placing them on C:\images
. The only solution that I have know to handle the path of @app/web/images
is just like the previous comment but as regarded it causes issue with image url in ckeditor.
However, I like to mention that I'm using the app on Apache's Virtual Host where its document root is:
C:\xampp\yii2app\web
.
Where could I able to echo FILES_ROOT
?
The following combination works for the file manager:
$ret = (Module::isAdvanced())? FileHelper::fixPath(Yii::getAlias('@frontend/web/') . FILES_ROOT) : 'C:/xampp-3/htdocs/yii2app/web' . FILES_ROOT;
@ line 190 of RoxyHelper.php since I'm using basic application, I set the path manullay. and in the module configuration @ web.php 'FILES_ROOT' => './images'
without the leading dot
. it does not works and points to wrong path.
However, I need it to be without dot to allow correct image URL insertion in CKEditor since the value passed from the file manager to CKEditor is the FILES_ROOT + filename
.
Obviously there is a problem when FILES_ROOT
prefixed with slash / on Windows
can you show your config/web.php
?
in yii2-basic Yii::getAlias('@app/web/')
always return DOCUMENT_ROOT/your_app/web/
in your case: this will return C:/xampp-3/htdocs/yii2app/web/
ps. I use Windows too
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'name' => 'Translation Site',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'layout' => 'trans-other',
'components' => [
'i18n' => [
'translations' => [
'bakr' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
],
],
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'hkQvgDmZidXG0GYaQn98VmjkQ1oVlLFx',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'suffix' => '.html',
'rules' => [
'/' => 'site/index',
'aboutus' => 'site/about',
'partners' => 'site/partners',
'languages' => 'site/languages',
'login' => 'site/login',
],
],
],
'params' => $params,
'modules' => [
'roxymce' => [
'class' => '\navatech\roxymce\Module',
'config' => [
'FILES_ROOT' => "./images",
],
],
],
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
Also, I'd like to mention that I use Apache's virtual host where the document root is the Yii web directory. However, the project directory itself is also sub directory of the Apache's htdocs.
Did you have tried to set the FILES_ROOT
property to some path starts with slash? i.e /images
why must set FILES_ROOT
started with slash?
as I said above
you just simple define:
'FILES_ROOT' => 'images'
Because images
makes it added to CKeditor as images/photo_name.png
which makes it to be invalid image path. It should be started with slash to be compatible with site root URL i.e mydomain.com/images/photo_name.png
from any URL level.
Sorry @saidbakr I checked on un-commit version. Just committed, please update it.
you just simple define:
'FILES_ROOT' => 'images'
@phuong17889 Unfortunately, the last update that you regarded does not work at all. f4f73ab => 04245a5
The output of roxymce/manager/dirlist/?type=image
PHP Warning – yii\base\ErrorException opendir(C:/xampp-3/htdocs/translationC:/xampp-3/htdocs/translation/uploads/image,C:/xampp-3/htdocs/translationC:/xampp-3/htdocs/translation/uploads/image): The filename, directory name, or volume label syntax is incorrect. (code: 123)
I think that you have to set two properties for the path. One of them is public and the other is private. Suppose my case:
C:/xampp-3/htdocs/yii2app/web/images
The portion in bold should be public and it should be defined by a property with suggested name: FILES_WEB_ROOT
while the rest in normal font should be private and called FILES_SYS_ROOT
, If you noticed, the suggested FILES_SYS_ROOT
is the output of Yii2 getAlias('webroot')
. Also the second portion FILES_WEB_ROOT
will passed to the text editor, CKeditor or Tinymice to handle will the web paths.
In addition, I think it may be better to label this post as a bug.
@saidbakr your URL is http://localhost/yii2app/web/
, right?
@phuong17889 No, as I have said before, I'm using virtual host. Typically, I access it using the URL http://yii2app.fox
I have updated to the latest dev commit commit 44 -2902a12- and I solved the issue like the following:
RoxyHelper::getFilesPath becomes as follows:
public static function getFilesPath() {
$ret = FileHelper::fixPath(Yii::getAlias('@webroot') .'/'. FILES_ROOT);
$tmp = $_SERVER['DOCUMENT_ROOT'];
if (in_array(mb_substr($tmp, - 1), [
'/',
'\\',
], true)) {
$tmp = mb_substr($tmp, 0, - 1);
}
$ret = str_replace(FileHelper::fixPath($tmp), '', $ret);
return $ret;
}
In addition any path alias @common and @web changed to @webroot without any slashes. any required slash should be concatenated with the output as shown in the above example.
By the way, I have turned to Tinymce editor and I migrate CKeditor.
@saidbakr thanks, but commit #44 is not for this I think it's roxyfileman's bug or maybe not compatible with my code. I'm trying to dev another version, that's not using roxyfileman in commit #43, if I used virtualhost, everything will be ok.
FILE_ROOT
is not accept Yii path alias such as@web
. When I setFILE_ROOT =>
@web/imagesit creates folder
C:\@web\imageswhile my Yii2 application is found at
C:\xampp\htdocs\yii2app`.