From 4da7024f910e623d1c6845755e542fcd0ac2cda3 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 15 Jan 2013 11:47:31 +0000 Subject: [PATCH] Upload files function added This function will get uploaded file details for each file uploaded and when uploaded, move the file to the user selected folder. Also shows error message if there is an issue. Either way, when finished it will clear the selectedFiles, file menu and hide the loading mask to return user to normal view. --- lib/file-control.php | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/file-control.php b/lib/file-control.php index e86b1b4..d2c5099 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -92,6 +92,52 @@ if ($_GET['action']=="paste") { echo ''; } +// If we're due to upload files... +if ($_GET['action']=="upload") { + if (!$demoMode) { + class fileUploader { + public function __construct($uploads) { + global $docRoot; + $uploadDir=$docRoot.$iceRoot.str_replace("|","/",strClean($_POST['folder'])."/"); + foreach($uploads as $current) { + $this->uploadFile=$uploadDir.$current->name; + $fileName = $current->name; + if ($this->upload($current,$this->uploadFile)) { + echo ''; + } else { + echo ""; + } + } + } + + public function upload($current,$uploadFile){ + if(move_uploaded_file($current->tmp_name,$uploadFile)){ + return true; + } + } + } + + function getDetails($fileArr) { + foreach($fileArr['name'] as $keyee => $info) { + $uploads[$keyee]->name=$fileArr['name'][$keyee]; + $uploads[$keyee]->type=$fileArr['type'][$keyee]; + $uploads[$keyee]->tmp_name=$fileArr['tmp_name'][$keyee]; + $uploads[$keyee]->error=$fileArr['error'][$keyee]; + } + return $uploads; + } + + if($_FILES['filesInput']){ + $uploads = getDetails($_FILES['filesInput']); + $fileUploader=new fileUploader($uploads); + } + } else { + echo ""; + } + + echo ""; +} + // If we're due to rename a file/folder... if ($_GET['action']=="rename") { if (!$demoMode && is_writable($docRoot.$iceRoot.str_replace("|","/",strClean($_GET['oldFileName'])))) {