Exemple #1
0
$oFU = new WYFileUpload("upload");
$bOK = false;
$sResponse = "";
$sURL = "";
if (isset($_REQUEST['CKEditor'])) {
    if ($oFU->bUploadOK()) {
        $oOriginalName = od_clone($oFU->oOriginalFilename());
        if ($oOriginalName->bCheck(WYPATH_CHECK_NOSCRIPT | WYPATH_CHECK_NOPATH | WYPATH_CHECK_JUSTIMAGE)) {
            $sFilename = $oOriginalName->sPath;
            $sExtension = $oOriginalName->sExtension();
            $sFilename = str_replace(".{$sExtension}", "", $sFilename);
            $sFilename = WYPath::sMakeFilename($sFilename);
            $oDestPath = od_clone($goApp->oDataPath);
            $sDestFilename = "rtimg-{$sFilename}.{$sExtension}";
            $oDestPath->addComponent($sDestFilename);
            $oFile = new WYFile($oFU->oFilePath());
            if (!$oFile->bCopyTo($oDestPath)) {
                $goApp->log("Could not copy uploaded image file");
                $sResponse = WYTS("FileUploadErrorUnknown", false);
            } else {
                $sResponse = "";
                $bOK = true;
                $oURL = od_clone($goApp->oDataURL);
                $oURL->addComponent($sDestFilename);
                $sURL = $oURL->sURL(false, false, true);
            }
        } else {
            $goApp->log("Illegal file/type on attachment upload: " . $oOFP->sPath);
            $sResponse = WYTS("FileUploadErrorUnknown", false);
        }
        $oFU->deleteTmpFile();
Exemple #2
0
 // if about to save, ...
 if ($bNewImage) {
     // ...and there is at least one new image, ...
     for ($j = 0; $j < $oFU->iNrOfFiles; $j++) {
         // ...save ALL files, ...
         $bHasError = false;
         $iImageID++;
         if ($oFU->bFileUploaded($j) && !$oFU->bUploadOK($j)) {
             $sResponse .= $oFU->sErrorMessage(true, $j);
             $iNrOfErrors++;
             $iImageID--;
             $bHasError = true;
         } else {
             // ...which DONT have errors
             if ($oFU->bFileUploaded($j)) {
                 $oFP =& $oFU->oFilePath($j);
                 $oOFP =& $oFU->oOriginalFilename($j);
                 if ($oOFP->bCheck(WYPATH_CHECK_JUSTIMAGE | WYPATH_CHECK_NOPATH)) {
                     $oElement->newImageAfter($iImageID - 1);
                     // insert new slot, only if upload happened AND is ok
                     $oElement->useUploadedImageFileForID($oFP, $oOFP, $iImageID);
                 } else {
                     $goApp->log('Illegal file/type on image upload: ' . $oOFP->sPath);
                     $sResponse .= '<span style="color:red">' . WYTS('FileUploadErrorUnknown') . ' &quot;' . $oOFP->sPath . "&quot;</span><br />\n";
                     $iNrOfErrors++;
                     $iImageID--;
                     $bHasError = true;
                 }
                 $oFU->deleteTmpFile($j);
             }
             if (!$bHasError) {
Exemple #3
0
$oHFDelete = new WYHiddenField("DELETE_FILE");
$oFU = new WYFileUpload("AUDIO_FILE");
$oElement = new WYAudioElement($oEditor->sFieldName, "");
$oFP = od_nil;
$sMaxUpload = ini_get("upload_max_filesize");
$sMaxUpload = str_replace("M", "MB", $sMaxUpload);
$bOK = false;
if ((int) $oHFDelete->sValue() == 1) {
    $oElement->deleteFile();
    // implicit save
    $sResponse = WYTS("FileDeleted");
    $bOK = true;
} else {
    if ($oEditor->bSave) {
        if ($oFU->bUploadOK()) {
            $oFP =& $oFU->oFilePath();
            $oOFP =& $oFU->oOriginalFilename();
            if ($oOFP->bCheck(WYPATH_CHECK_JUSTAUDIO | WYPATH_CHECK_NOPATH)) {
                $oElement->useUploadedFile($oFP, $oFU->oOriginalFilename());
                $oElement->save();
                $sResponse = WYTS("FileSaved");
                $bOK = true;
            } else {
                $goApp->log("Illegal file/type on audio upload: " . $oOFP->sPath);
                @unlink($oFP->sPath);
                $sResponse = WYTS("FileUploadErrorUnknown");
            }
        } else {
            $sResponse = $oFU->sErrorMessage();
        }
    }