src/Subjects/FileUploadTrait.php
/**
     * Delete the file with the passed name.
     *
     * @param string $filename The name of the file to be deleted
     *
     * @return boolean TRUE on success, else FALSE
     */
Delete the file with the passed name.
@param string $filename The name of the file to be deleted

@return boolean TRUE on success, else FALSE
Delete the file with the passed name . @param string $filename The name of the file to be deleted @return boolean TRUE on success else FALSE
public function deleteFile($filename)
    {
        $trimmedFilename = ltrim($filename, '/');
        $mediaDir = ltrim($this->getMediaDir(), '/');
        $targetFilename = sprintf('%s/%s', $mediaDir, $trimmedFilename);
        if (!$this->getFilesystemAdapter()->isFile($targetFilename)) {
            throw new \Exception(sprintf('Media file "%s" is not available', $targetFilename));
        }
        $this->getFilesystemAdapter()->delete($targetFilename);
    }
public function deleteFile ( $ filename ) { $ trimmedFilename = ltrim ( $ filename , '/' ) ; $ mediaDir = ltrim ( $ this -> getMediaDir ( ) , '/' ) ; $ targetFilename = sprintf ( '%s/%s' , $ mediaDir , $ trimmedFilename ) ; if ( ! $ this -> getFilesystemAdapter ( ) -> isFile ( $ targetFilename ) ) { throw new \ Exception ( sprintf ( 'Media file "%s" is not available' , $ targetFilename ) ) ; } $ this -> getFilesystemAdapter ( ) -> delete ( $ targetFilename ) ; }
Delete the file with the passed name.
Delete the file with the passed name .
// trim the leading /, if available // prepare source/target filename // query whether or not the image file to be deleted is available // delte the image from the target directory