yiidoc / yii2-redactor

Extension Redactor WYSIWYG for Yii2 framework
BSD 3-Clause "New" or "Revised" License
187 stars 87 forks source link

Setting a default directory via module configuration instead of only the owner path. #60

Open JoseNetoooo opened 8 years ago

JoseNetoooo commented 8 years ago

Hi!! I am using your plugin and that is my problem... In some projects I would like to set a different "directory" to save my images. In your extension you use the function $this->getOwnerPath() and the directory is always the user id or "guest". That is my proposal:

`class RedactorModule extends \yii\base\Module { // other variables public $directory = null;

// public function getDirectory() { return ($this->directory ? $this->directory : $this->getOwnerPath()); }

public function getSaveDir() { $path = Yii::getAlias($this->uploadDir) . DIRECTORY_SEPARATOR . $this->getDirectory(); if(!file_exists($path)){
if (!FileHelper::createDirectory($path, 0775,$recursive = true )) { throw new InvalidConfigException('$uploadDir does not exist and default path creation failed'); } } return $path; }

public function getUrl($fileName) { return Url::to($this->uploadUrl . '/' . $this->getDirectory() . '/' . $fileName); }

}`

Thanks so much for this plugin! It is very helpful for me!

Stunc0 commented 7 years ago

I'm using this plugin and i find this proposition well ! I'm interested to be able to set a directory for every uploads at the same place !

Stunc0 commented 7 years ago

any news ?

tsaffi commented 7 years ago

please. can any of you tell me how you did to upload an image??? because i don't know how to configure the uploadDir and uploadUrl in views, config and redactorModule (.php) files.