pathUploads() public static method

Return path to upload folder.
public static pathUploads ( ) : string
return string Path to upload folder.
Ejemplo n.º 1
0
 /**
  * Delete an uploaded file & its media record.
  *
  * @param int $MediaID Unique ID on Media table.
  */
 protected function trashFile($MediaID)
 {
     $Media = $this->mediaModel()->getID($MediaID);
     if ($Media) {
         $this->mediaModel()->delete($Media);
         $Deleted = false;
         // Allow interception
         $this->EventArguments['Parsed'] = Gdn_Upload::parse($Media->Path);
         $this->EventArguments['Handled'] =& $Deleted;
         // Allow skipping steps below
         $this->fireEvent('TrashFile');
         if (!$Deleted) {
             $DirectPath = MediaModel::pathUploads() . DS . $Media->Path;
             if (file_exists($DirectPath)) {
                 $Deleted = @unlink($DirectPath);
             }
         }
         if (!$Deleted) {
             $CalcPath = FileUploadPlugin::findLocalMedia($Media, true, true);
             if (file_exists($CalcPath)) {
                 @unlink($CalcPath);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  *
  *
  * @todo Refactor into different method to maintain compatibility with base class.
  *
  * @param array $Media The media row.
  * @param array|bool $Options Either a boolean that says whether or not to delete the file or an array with a
  */
 public function delete($Media = [], $Options = [])
 {
     if (is_bool($Options)) {
         $DeleteFile = $Options;
     } else {
         $DeleteFile = val('Delete', $Options, true);
     }
     $MediaID = false;
     if (is_a($Media, 'stdClass')) {
         $Media = (array) $Media;
     }
     if (is_numeric($Media)) {
         $MediaID = $Media;
     } elseif (array_key_exists('MediaID', $Media)) {
         $MediaID = $Media['MediaID'];
     }
     if ($MediaID) {
         $Media = $this->getID($MediaID);
         $this->SQL->delete($this->Name, array('MediaID' => $MediaID), false);
         if ($DeleteFile) {
             $DirectPath = MediaModel::pathUploads() . DS . val('Path', $Media);
             if (file_exists($DirectPath)) {
                 @unlink($DirectPath);
             }
         }
     } else {
         $this->SQL->delete($this->Name, $Media, false);
     }
 }