Would like to set up the new 'trash' option on an existing local volume, but running into issues...any help?
@dleffler There is an exsample in connector.minimal.php-dist.
Also note the access function.
@dleffler don't forget to add restore to your command list in the main JS file
Looks like my issue relates to the (poor) example using '.trash' for the folder name and the 'access' function locks read & write access to dot files?
Also, is there an easier way of determining the 'trashHash' option value? I had to load elFinder and then use the debug view and tracing javascript to determine the hash value of the trash volume. E.g., the send to trash worked, but needed the full trashHash root to get restore to work.
I also noted the trash folder MUST already exist to mount the trash volume. Though subfolders are automatically created, the main folder must exist at startup.
Also, is there an easier way of determining the 'trashHash' option value? I had to load elFinder and then use the debug view and tracing javascript to determine the hash value of the trash volume. E.g., the send to trash worked, but needed the full trashHash root to get restore to work.
Temporarily turn on useBrowserHistory in your elFinder opts main.js

Please share your setup. My restore does not work one bit. Thanks
option configuration is
```
'roots' => array(
array(
'id' => 'exp2',
'driver' => 'Exponent', // custom volume driver
'path' => BASE . 'files/',
'URL' => URL_FULL . 'files/',
'trashHash' => 'tt1_XA', // elFinder's hash of trash folder
'dirMode' => octdec(DIR_DEFAULT_MODE_STR + 0), // new dirs mode (default 0755)
'fileMode' => octdec(FILE_DEFAULT_MODE_STR + 0), // new files mode (default 0644)
'detectDirIcon' => '.foldericon.png',
'keepTimestamp' => array('copy', 'move'),
'disabled' => array('netmount'),
'accessControl' => 'access',
'uploadDeny' => array('all'), // All Mimetypes NOT allowed to upload
'uploadAllow' => array(...array of mimetypes...), // this is truncated for this example
'uploadOrder' => 'deny,allow',
'uploadOverwrite' => true,
'copyJoin' => true,
'tmbCrop' => false,
'tmbPath' => BASE . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder',
'tmbURL' => URL_FULL . 'tmp/elfinder/',
'tmbPathMode' => octdec(DIR_DEFAULT_MODE_STR + 0),
'tmbBgColor' => 'transparent',
'tmbSize' => FM_THUMB_SIZE,
'quarantine' => '..' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder' . DIRECTORY_SEPARATOR . '.quarantine',
'acceptedName' => '/^[^.].*$/',
'utf8fix' => false,
'attributes' => array(
array(
'pattern' => '/^\/./', // dot files are hidden
'read' => false,
'write' => false,
'hidden' => true,
'locked' => true
)
)
),
// Trash volume
array(
'id' => 't1',
'driver' => 'Trash',
'path' => BASE . 'files/.trash/',
'URL' => URL_FULL . 'files/.trash/',
'tmbPath' => BASE . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder',
'tmbURL' => URL_FULL . 'tmp/elfinder/',
'uploadDeny' => array('all'),
'uploadAllow' => array(...array of mimetypes...), // this is truncated for this example
'uploadOrder' => array('deny', 'allow'), // Same as above
'accessControl' => null, // grant access to the dot named folder
),
),
'''
I missed a T in 'trashHash' => 'tt1_XA',
We also got to watch out:
If say, Volume1 has filename rules acceptedName / acceptedDirname, e,g all files must have extension ...
and you delete LICENSE text file that has extension ...
When you restore that file, it will fail, because when the file is restored, all rules including acceptedName will be checked. The restored file is basically being treated as an copied/pasted/uploaded file
This specification to makes it possilbe to the Trash function without extends current API.
I strongly recommend that you set the same permissions as the target volume as a countermeasure against attack using the Trash.
As an example of allowing only root directory names beginning with ".", There is an access () function in connector.minimal.php-dist.
/**
* Simple function to demonstrate how to control file access using "accessControl" callback.
* This method will disable accessing files/folders starting from '.' (dot)
*
* @param string $attr attribute name (read|write|locked|hidden)
* @param string $path absolute file path
* @param string $data value of volume option `accessControlData`
* @param object $volume elFinder volume driver object
* @param bool|null $isDir path is directory (true: directory, false: file, null: unknown)
* @param string $relpath file path relative to volume root directory started with directory separator
* @return bool|null
**/
function access($attr, $path, $data, $volume, $isDir, $relpath) {
$basename = basename($path);
return $basename[0] === '.' // if file/folder begins with '.' (dot)
&& strlen($relpath) !== 1 // but with out volume root
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
: null; // else elFinder decide it itself
}
Hi,
I'm having trouble for the trash function. Attached the code I use
el-opts.txt
When I try to trash an item, I have the error
Impossible to create folder "".
Invalid folder name.
@nico3dfx Please try newest nightly build. And please don't forget clearing browser cache.
Most helpful comment
option configuration is
```
'roots' => array(
array(
'id' => 'exp2',
'driver' => 'Exponent', // custom volume driver
'path' => BASE . 'files/',
'URL' => URL_FULL . 'files/',
'trashHash' => 'tt1_XA', // elFinder's hash of trash folder
'dirMode' => octdec(DIR_DEFAULT_MODE_STR + 0), // new dirs mode (default 0755)
'fileMode' => octdec(FILE_DEFAULT_MODE_STR + 0), // new files mode (default 0644)
'detectDirIcon' => '.foldericon.png',
'keepTimestamp' => array('copy', 'move'),
'disabled' => array('netmount'),
'accessControl' => 'access',
'uploadDeny' => array('all'), // All Mimetypes NOT allowed to upload
'uploadAllow' => array(...array of mimetypes...), // this is truncated for this example
'uploadOrder' => 'deny,allow',
'uploadOverwrite' => true,
'copyJoin' => true,
'tmbCrop' => false,
'tmbPath' => BASE . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder',
'tmbURL' => URL_FULL . 'tmp/elfinder/',
'tmbPathMode' => octdec(DIR_DEFAULT_MODE_STR + 0),
'tmbBgColor' => 'transparent',
'tmbSize' => FM_THUMB_SIZE,
'quarantine' => '..' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder' . DIRECTORY_SEPARATOR . '.quarantine',
'acceptedName' => '/^[^.].*$/',
'utf8fix' => false,
'attributes' => array(
array(
'pattern' => '/^\/./', // dot files are hidden
'read' => false,
'write' => false,
'hidden' => true,
'locked' => true
)
)
),
// Trash volume
array(
'id' => 't1',
'driver' => 'Trash',
'path' => BASE . 'files/.trash/',
'URL' => URL_FULL . 'files/.trash/',
'tmbPath' => BASE . 'tmp' . DIRECTORY_SEPARATOR . 'elfinder',
'tmbURL' => URL_FULL . 'tmp/elfinder/',
'uploadDeny' => array('all'),
'uploadAllow' => array(...array of mimetypes...), // this is truncated for this example
'uploadOrder' => array('deny', 'allow'), // Same as above
'accessControl' => null, // grant access to the dot named folder
),
),
'''