Ejemplo n.º 1
0
<?php

/**
 * Created by PhpStorm.
 * User: roessler
 * Date: 9/24/15
 * Time: 11:50 AM
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_POST['image'])) {
    $image = $_POST['image'];
    $mediaCon = new MediaController();
    $media = $mediaCon->deleteMedia($image['media_id']);
    $mediaResult = array();
    if ($media->errorInfo()[2] == null) {
        $mediaResult['media_id'] = $image['media_id'];
        $mediaResult['dbDelete'] = true;
        $filePath = 'D:' . DIRECTORY_SEPARATOR . 'Students' . $image['file_path'];
        $filePath = str_replace('FIT2076_', 'FIT2076' . DIRECTORY_SEPARATOR, $filePath);
        if (unlink($filePath)) {
            $mediaResult['fileDelete'] = true;
        }
        $dirPath = dirname($filePath);
        if (count(scandir($dirPath)) <= 2) {
            if (rmdir($dirPath)) {
                $mediaResult['dirDelete'] = true;
            }
        }
        $mediaResult = json_encode($mediaResult);
        print_r($mediaResult);
        return json_encode($mediaResult);
Ejemplo n.º 2
0
             $f = $result->fetch();
             $featureIds[] = $f['feature_id'];
             $featureNames[] = $f['feature_name'];
             $features[] = $f;
         }
         $result = $foCon->deleteFeatureForOffer($offerId);
         if ($result->errorInfo()[2] != null) {
             $deleteResult = $result->errorInfo()[2];
         }
     }
 }
 if ($deleteResult == null) {
     if (isset($_POST['mediaIds'])) {
         if (!empty($_POST['mediaIds'])) {
             foreach ($_POST['mediaIds'] as $mediaId) {
                 $result = $mediaCon->deleteMedia($mediaId);
                 if ($result->errorInfo()[2] != null) {
                     $deleteResult = $result->errorInfo()[2];
                 }
             }
         }
         if ($deleteResult == null) {
             if (isset($_POST['mediaFilePaths'])) {
                 if (!empty($_POST['mediaFilePaths'])) {
                     foreach ($_POST['mediaFilePaths'] as $mediafilePath) {
                         $filePath = 'D:' . DIRECTORY_SEPARATOR . 'Students' . $mediafilePath;
                         $filePath = str_replace('FIT2076_', 'FIT2076' . DIRECTORY_SEPARATOR, $filePath);
                         unlink($filePath);
                         $dirPath = dirname($filePath);
                         if (count(scandir($dirPath)) <= 2) {
                             rmdir($dirPath);