Esempio n. 1
0
 public static function saveFile($file, $form)
 {
     if (!is_uploaded_file($file['tmp_name'])) {
         return $form;
     }
     $fileName = mediaUtils::fixFileName($file['name']);
     $fileDir = dir::media($fileName);
     $extension = substr(strrchr($fileName, '.'), 1);
     // z.B. jpg
     $badExtensions = dyn::get('addons')['badExtensions'];
     // Wenn die Datei eine "verbotene" Datei ist
     if (in_array($extension, $badExtensions)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_bad_extension'), $file['name']));
         return $form;
     }
     if ($form->isEditMode()) {
         $media = new media(type::super('id', 'int', 0));
     }
     // Wenn Datei nicht Existiert
     // Oder man möchte sie überspeichern
     if ($form->isEditMode() && $media->get('filename') != $fileName || !$form->isEditMode() && file_exists($fileDir)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_already_exist'), $file['name']));
         return $form;
     }
     if (!move_uploaded_file($file['tmp_name'], $fileDir)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_move'), $file['name']));
         return $form;
     }
     $form->addPost('filename', $fileName);
     $form->addPost('size', filesize($fileDir));
     return $form;
 }
Esempio n. 2
0
        echo lang::get('add');
        ?>
</a>
					</div>
                    <?php 
    }
    ?>
					<div class="clearfix"></div>
                </div>
				<div class="panel-body">
					<form action="index.php" method="get">
						<input type="hidden" name="page" value="media" />
						<input type="hidden" name="subpage" value="files" />
						<select class="form-control" id="media-select-category" name="catId">
							<?php 
    echo mediaUtils::getTreeStructure(0, 0, ' &nbsp;', $catId);
    ?>
						</select>
					</form>
				</div>
                <form action="index.php" method="post">
                	<input type="hidden" name="page" value="media" />
                    <input type="hidden" name="subpage" value="files" />
                    <input type="hidden" name="action" value="deleteFiles" />
                	<?php 
    echo $table->show();
    ?>
                </form>
            </div>
        </div>
    </div>