protected function SaveWikiVersion()
 {
     // Validate it as a valid image file
     switch (QMimeType::GetMimeTypeForFile($this->flcImage->File)) {
         case QMimeType::Gif:
         case QMimeType::Jpeg:
         case QMimeType::Png:
             break;
         default:
             $this->flcImage->Warning = 'Must be a PNG, JPEG or GIF file';
             return null;
     }
     // Create the Parameters for Save
     $objWikiImage = new WikiImage();
     $objWikiImage->Description = trim($this->txtDescription->Text);
     $arrMethodParameters = array($this->flcImage->File);
     $objWikiVersion = $this->objWikiItem->CreateNewVersion(trim($this->txtTitle->Text), $objWikiImage, 'SaveFile', $arrMethodParameters, QApplication::$Person, null);
     return $objWikiVersion;
 }
Beispiel #2
0
 public function __construct($strFilePath, $strSpecifiedMimeType = null, $strSpecifiedFileName = null)
 {
     // Set File Path
     if (!is_file(realpath($strFilePath))) {
         throw new QCallerException('File Not Found: ' . $strFilePath);
     }
     $this->strFilePath = realpath($strFilePath);
     // Set the File MIME Type -- if Explicitly Set, use it
     if ($strSpecifiedMimeType) {
         $this->strMimeType = $strSpecifiedMimeType;
     } else {
         $this->strMimeType = QMimeType::GetMimeTypeForFile($this->strFilePath);
     }
     // Set the File Name -- if explicitly set, use it
     if ($strSpecifiedFileName) {
         $this->strFileName = $strSpecifiedFileName;
     } else {
         $this->strFileName = basename($this->strFilePath);
     }
     // Read file into a Base64 Encoded Data Stream
     $strFileContents = file_get_contents($this->strFilePath, false);
     $this->strEncodedFileData = chunk_split(base64_encode($strFileContents));
 }