Yii Framework Forum: The path alias works in two ways - Yii2 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

The path alias works in two ways - Yii2 Rate Topic: -----

#1 User is offline   futur1st 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-January 18

Posted 11 February 2018 - 02:25 AM

Hi, i have a such problem:
In Yii2 advanced, in common/config/bootsrap.php has created @alias in which it is necessary to store photos, but there is a problem:

- if the script runs on the frontend - then the @folder is created in
one place
- and if the script runs on the backend - then the @folder is created
elsewhere.

How to make so that the folder was created only in frontend?

More information:

Image with directory structure:
Attached File  stack.png (15.41K)
Number of downloads: 1

.htaccess file code for both files
Attached File  htt.png (6K)
Number of downloads: 1

Code for: backend/controllers/ActionThatCreateTheDirecotry:
$dir = Yii::getAlias('@images') . '/blog/';
FileHelper::createDirectory($dir);
0

#2 User is offline   futur1st 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-January 18

Posted 16 February 2018 - 01:32 AM

I maked the next modifications and it's working:
Yii::setAlias('@images', dirname(dirname(dirname(DIR))) . '/../uploads/images');
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users