From b433bcc5da665c171b2ac293892d3d19eef80e2f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 25 Jan 2012 12:47:58 +0100 Subject: allow client to overwrite filename Signed-off-by: Florian Pritz --- application/controllers/file.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'application') diff --git a/application/controllers/file.php b/application/controllers/file.php index 0c2db3e0c..4bb336ad0 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -233,7 +233,18 @@ class File extends CI_Controller { $id = $this->file_mod->new_id(); $hash = md5_file($_FILES['file']['tmp_name']); - $filename = $_FILES['file']['name']; + + // work around a curl bug and allow the client to send the real filename base64 encoded + $filename = $this->input->post("filename"); + if ($filename !== false) { + $filename = base64_decode($filename, true); + } + + // fall back if base64_decode failed + if ($filename === false) { + $filename = $_FILES['file']['name']; + } + $folder = $this->file_mod->folder($hash); file_exists($folder) || mkdir ($folder); $file = $this->file_mod->file($hash); -- cgit v1.2.3-24-g4f1b