From e682125a03fd7f6ff3ec354d1fa169ed52033509 Mon Sep 17 00:00:00 2001 From: Julian Seidenberg Date: Tue, 7 Aug 2012 16:56:17 +1200 Subject: [PATCH] BUGFIX: removing restriction that the uploaded file needs to have the same name as the previous file. The client specifically needs to be able to upload a new file with a different name. --- code/cms/DMSUploadField.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/code/cms/DMSUploadField.php b/code/cms/DMSUploadField.php index 8f4776e..62efe8f 100644 --- a/code/cms/DMSUploadField.php +++ b/code/cms/DMSUploadField.php @@ -55,26 +55,6 @@ class DMSUploadField extends UploadField { public function upload(SS_HTTPRequest $request) { if($this->isDisabled() || $this->isReadonly()) return $this->httpError(403); - // CUSTOM Validate that the replaced file is of the same name, - // as we don't support altering the file attributes after initial upload - $record = $this->getRecord(); - if($record instanceof DMSDocument) { - $tmpfile = $request->postVar($this->getName()); - $suggestedFileName = basename(FileNameFilter::create()->filter($tmpfile['name'])); - if($suggestedFileName != $record->getFilenameWithoutID()) { - $return = array( - 'error' => _t( - 'DMSUploadField.WRONGNAME', - 'The new file name needs to match the one being replaced' - ) - ); - $response = new SS_HTTPResponse(Convert::raw2json(array($return))); - $response->addHeader('Content-Type', 'text/plain'); - return $response; - } - } - // CUSTOM END - // Protect against CSRF on destructive action $token = $this->getForm()->getSecurityToken(); if(!$token->checkRequest($request)) return $this->httpError(400);