delete() 공개 메소드

Delete an uploaded file.
public delete ( string $Name ) : boolean
$Name string The name of the upload as saved in the database.
리턴 boolean
예제 #1
0
 /**
  * Remove the photo from a user.
  *
  * @param int $UserID
  */
 public function removePicture($UserID)
 {
     // Grab the current photo.
     $User = $this->getID($UserID, DATASET_TYPE_ARRAY);
     $Photo = $User['Photo'];
     // Only attempt to delete a physical file, not a URL.
     if (!isUrl($Photo)) {
         $ProfilePhoto = changeBasename($Photo, 'p%s');
         $Upload = new Gdn_Upload();
         $Upload->delete($ProfilePhoto);
     }
     // Wipe the Photo field.
     $this->setField($UserID, 'Photo', null);
 }
 /**
  * Deletes uploaded default avatars.
  *
  * @param string $avatar The avatar to delete.
  */
 private function deleteDefaultAvatars($avatar = '')
 {
     if ($avatar && $this->isUploadedDefaultAvatar($avatar)) {
         $upload = new Gdn_Upload();
         $upload->delete(self::DEFAULT_AVATAR_FOLDER . '/' . basename($avatar));
         $upload->delete(self::DEFAULT_AVATAR_FOLDER . '/' . basename(changeBasename($avatar, 'p%s')));
         $upload->delete(self::DEFAULT_AVATAR_FOLDER . '/' . basename(changeBasename($avatar, 'n%s')));
     }
 }
 /**
  * Remove the share image from config & delete it.
  *
  * @since 2.1
  * @param string $TransientKey Security token.
  */
 public function removeShareImage($TransientKey = '')
 {
     $this->permission('Garden.Community.Manage');
     if (Gdn::request()->isAuthenticatedPostBack()) {
         $ShareImage = c('Garden.ShareImage', '');
         removeFromConfig('Garden.ShareImage');
         $Upload = new Gdn_Upload();
         $Upload->delete($ShareImage);
     }
     $this->RedirectUrl = '/settings/banner';
     $this->render('Blank', 'Utility');
 }
예제 #4
0
 /**
  * Delete a screenshot from an addon.
  *
  * @param string $AddonPictureID Picture id to remove.
  * @throws Gdn_UserException No permission to delete this picture.
  */
 public function deletePicture($AddonPictureID = '')
 {
     $AddonPictureModel = new Gdn_Model('AddonPicture');
     $Picture = $AddonPictureModel->getWhere(array('AddonPictureID' => $AddonPictureID))->firstRow();
     $AddonModel = new AddonModel();
     $Addon = $AddonModel->getID($Picture->AddonID);
     $Session = Gdn::session();
     if ($Session->UserID != $Addon['InsertUserID'] && !$Session->checkPermission('Addons.Addon.Manage')) {
         throw permissionException();
     }
     if ($this->Form->authenticatedPostBack() && $this->Form->getFormValue('Yes')) {
         if ($Picture) {
             $Upload = new Gdn_Upload();
             $Upload->delete(changeBasename($Picture->File, 'ao%s'));
             $Upload->delete(changeBasename($Picture->File, 'at%s'));
             $AddonPictureModel->delete(array('AddonPictureID' => $AddonPictureID));
         }
         $this->RedirectUrl = url('/addon/' . $Picture->AddonID);
     }
     $this->render('deletepicture');
 }
예제 #5
0
 /**
  * Remove the photo from a user.
  *
  * @param $UserID
  */
 public function removePicture($UserID)
 {
     // Grab the current photo.
     $User = $this->getID($UserID, DATASET_TYPE_ARRAY);
     if ($Photo = $User['Photo']) {
         $ProfilePhoto = changeBasename($Photo, 'p%s');
         $Upload = new Gdn_Upload();
         $Upload->delete($ProfilePhoto);
         $this->setField($UserID, 'Photo', null);
     }
 }
예제 #6
0
 /**
  * Deletes uploaded avatars in the profile size format.
  *
  * @param string $avatar The avatar to delete.
  */
 private function deleteAvatars($avatar = '')
 {
     if ($avatar && $this->isUploadedAvatar($avatar)) {
         $upload = new Gdn_Upload();
         $subdir = stringBeginsWith(dirname($avatar), PATH_UPLOADS . '/', false, true);
         $upload->delete($subdir . '/' . basename(changeBasename($avatar, 'p%s')));
     }
 }