/**
  * Upload an image to an HTML galley.
  * @param $imageName string file input key
  */
 function uploadImage()
 {
     import('classes.file.PaperFileManager');
     $fileManager = new PaperFileManager($this->paperId);
     $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
     $fileName = 'imageFile';
     if (isset($this->galley) && $fileManager->uploadedFileExists($fileName)) {
         $type = $fileManager->getUploadedFileType($fileName);
         $extension = $fileManager->getImageExtension($type);
         if (!$extension) {
             $this->addError('imageFile', Locale::translate('submission.layout.imageInvalid'));
             return false;
         }
         if ($fileId = $fileManager->uploadPublicFile($fileName)) {
             $galleyDao->insertGalleyImage($this->galleyId, $fileId);
             // Update galley image files
             $this->galley->setImageFiles($galleyDao->getGalleyImages($this->galleyId));
         }
     }
 }