From 84baa9e14a3d7c7635d110278d830b8a4c04a8b0 Mon Sep 17 00:00:00 2001 From: Prasath Mani Date: Fri, 24 Aug 2018 18:01:58 +0530 Subject: [PATCH] #52 Does not respect directory tree while uploading a folder containing sub-folders --- tinyfilemanager.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index dd87129..b81e081 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -449,6 +449,7 @@ if (isset($_GET['dl'])) { if (!empty($_FILES) && !FM_READONLY) { $f = $_FILES; $path = FM_ROOT_PATH; + $ds = DIRECTORY_SEPARATOR; if (FM_PATH != '') { $path .= '/' . FM_PATH; } @@ -463,8 +464,18 @@ if (!empty($_FILES) && !FM_READONLY) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true; + $targetPath = $path . $ds; + $fullPath = $path.'/'.$_REQUEST['fullpath']; + $folder = substr($fullPath, 0, strrpos($fullPath, "/")); + + if (!is_dir($folder)) { + $old = umask(0); + mkdir($folder, 0777, true); + umask($old); + } + if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) { - if (move_uploaded_file($tmp_name, $path . '/' . $f['file']['name'])) { + if (move_uploaded_file($tmp_name, $fullPath)) { die('Successfully uploaded'); } else { die(sprintf('Error while uploading files. Uploaded files: %s', $uploads)); @@ -689,12 +700,15 @@ if (isset($_GET['upload']) && !FM_READONLY) { - +

Uploading files

Destination folder:

-