[GH-ISSUE #293] Can create and delete folders but not rename #212

Closed
opened 2026-03-02 15:56:54 +03:00 by kerem · 8 comments
Owner

Originally created by @yumyo on GitHub (Jan 22, 2020).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/293

The error is generic but given I can both create and delete (and open) it does not seem related to permissions, is it?

Originally created by @yumyo on GitHub (Jan 22, 2020). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/293 The error is generic but given I can both create and delete (and open) it does not seem related to permissions, is it?
kerem 2026-03-02 15:56:54 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@yumyo commented on GitHub (Jan 22, 2020):

error_reporting to true does not help. Some info:

TFM Tiny File Manager 2.4.1
PHP 5.5.9-1ubuntu4.29 (fpm-fcgi)
[PHP Modules]
bcmath
bz2
calendar
cgi-fcgi
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
mhash
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

<!-- gh-comment-id:577297175 --> @yumyo commented on GitHub (Jan 22, 2020): error_reporting to true does not help. Some info: TFM Tiny File Manager 2.4.1 PHP 5.5.9-1ubuntu4.29 (fpm-fcgi) [PHP Modules] bcmath bz2 calendar cgi-fcgi Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv imagick json libxml mbstring mhash mysql mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter Zend OPcache zip zlib [Zend Modules] Zend OPcache
Author
Owner

@yumyo commented on GitHub (Jan 22, 2020):

Also, can rename files but NOT folders, regardless they have been uploaded or created within TFM

<!-- gh-comment-id:577322425 --> @yumyo commented on GitHub (Jan 22, 2020): Also, can rename files but NOT folders, regardless they have been uploaded or created within TFM
Author
Owner

@prasathmani commented on GitHub (Jan 23, 2020):

Even I'm not sure, mostly it related to permissions and environment related, try to change the folder permission

<!-- gh-comment-id:577500061 --> @prasathmani commented on GitHub (Jan 23, 2020): Even I'm not sure, mostly it related to permissions and environment related, try to change the folder permission
Author
Owner

@yumyo commented on GitHub (Jan 23, 2020):

Thank you for your prompt reply @prasathmani
I'd agree it surely must be, tho it's quite strange. folders are on 777 at the moment but it's not helping. The only not so common thing in my setup might be that TinyFileManager (which is amazing by the way!) does just live in a folder of a domain.
So in my setup I have:

$root_path = $_SERVER['DOCUMENT_ROOT'].'/upload';   
$root_url = '';   

With this settings I am able to perform any operation except renaming.
However, if I set `$root_url = ''/upload";`` as it seems suggested elsewhere, trying to open any file results in a 404. Thus I guess the two variables above are correct in my case?

<!-- gh-comment-id:577596715 --> @yumyo commented on GitHub (Jan 23, 2020): Thank you for your prompt reply @prasathmani I'd agree it surely must be, tho it's quite strange. folders are on 777 at the moment but it's not helping. The only not so common thing in my setup might be that TinyFileManager (which is amazing by the way!) does just live in a folder of a domain. So in my setup I have: ``` $root_path = $_SERVER['DOCUMENT_ROOT'].'/upload'; $root_url = ''; ``` With this settings I am able to perform any operation except renaming. However, if I set `$root_url = ''/upload";`` as it seems suggested elsewhere, trying to open any file results in a 404. Thus I guess the two variables above are correct in my case?
Author
Owner

@prasathmani commented on GitHub (Jan 23, 2020):

correct configuration:

$root_path = $_SERVER['DOCUMENT_ROOT'].'/upload';   
$root_url = 'upload';  

in 2.4.0 release, added some restriction to rename files, file name should not contain '/?%*:|"<>'.

<!-- gh-comment-id:577661266 --> @prasathmani commented on GitHub (Jan 23, 2020): correct configuration: ```php $root_path = $_SERVER['DOCUMENT_ROOT'].'/upload'; $root_url = 'upload'; ``` in 2.4.0 release, added some restriction to rename files, file name should not contain `'/?%*:|"<>'`.
Author
Owner

@yumyo commented on GitHub (Jan 23, 2020):

If I set $root_url to upload, like:

$root_path = $_SERVER['DOCUMENT_ROOT'].'/upload';   
$root_url = 'upload';

trying to open any item results in a 404, where the URL is:

https://[DOMAIN-HERE]/uploadupload/uploads/test/10/10.html

Instead, if I set;

$root_path = $_SERVER['DOCUMENT_ROOT'].'/upload';   
$root_url = '';

everything is correct and working and the URL is:

https://[DOMAIN-HERE]/upload/uploads/test/10/10.html

Well, everything except renaming folders ... renaming files works as stated before.
Owner:Group are the same, permissions still all set to 777

<!-- gh-comment-id:577704477 --> @yumyo commented on GitHub (Jan 23, 2020): If I set **$root_url** to **upload**, like: ``` $root_path = $_SERVER['DOCUMENT_ROOT'].'/upload'; $root_url = 'upload'; ``` trying to open any item results in a 404, where the URL is: [https://[DOMAIN-HERE]/uploadupload/uploads/test/10/10.html](https://[DOMAIN-HERE]/uploadupload/uploads/test/10/10.html) Instead, if I set; ``` $root_path = $_SERVER['DOCUMENT_ROOT'].'/upload'; $root_url = ''; ``` everything is correct and working and the URL is: [https://[DOMAIN-HERE]/upload/uploads/test/10/10.html](https://[DOMAIN-HERE]/upload/uploads/test/10/10.html) Well, everything except renaming folders ... renaming files works as stated before. Owner:Group are the same, permissions still all set to 777
Author
Owner

@swarfer commented on GitHub (Aug 27, 2020):

The problem is that folders generally do not have extensions so the check for allowed extensions fails.
I have added is_dir() to fm_rename() like this:
function fm_rename($old, $new)
{
$isFileAllowed = fm_is_valid_ext($new) || is_dir($old);

if(!$isFileAllowed) return false;

return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;

}

<!-- gh-comment-id:681699218 --> @swarfer commented on GitHub (Aug 27, 2020): The problem is that folders generally do not have extensions so the check for allowed extensions fails. I have added is_dir() to fm_rename() like this: function fm_rename($old, $new) { $isFileAllowed = fm_is_valid_ext($new) || is_dir($old); if(!$isFileAllowed) return false; return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null; }
Author
Owner

@soiqualang commented on GitHub (Oct 26, 2022):

The problem is that folders generally do not have extensions so the check for allowed extensions fails. I have added is_dir() to fm_rename() like this: function fm_rename($old, $new) { $isFileAllowed = fm_is_valid_ext($new) || is_dir($old);

if(!$isFileAllowed) return false;

return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;

}

Thanks, this's work!

<!-- gh-comment-id:1291474503 --> @soiqualang commented on GitHub (Oct 26, 2022): > The problem is that folders generally do not have extensions so the check for allowed extensions fails. I have added is_dir() to fm_rename() like this: function fm_rename($old, $new) { $isFileAllowed = fm_is_valid_ext($new) || is_dir($old); > > ``` > if(!$isFileAllowed) return false; > > return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null; > ``` > > } Thanks, this's work!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#212
No description provided.