public function deleteFile($filename)
    {

        // trim the leading /, if available
        $trimmedFilename = ltrim($filename, '/');
        $mediaDir = ltrim($this->getMediaDir(), '/');

        // prepare source/target filename
        $targetFilename = sprintf('%s/%s', $mediaDir, $trimmedFilename);

        // query whether or not the image file to be deleted is available
        if (!$this->getFilesystemAdapter()->isFile($targetFilename)) {
            throw new \Exception(sprintf('Media file %s not available', $targetFilename));
        }

        // delte the image from the target directory
        $this->getFilesystemAdapter()->delete($targetFilename);
    }
public function deleteFile($filename)
    {

        // trim the leading /, if available
        $trimmedFilename = ltrim($filename, '/');
        $mediaDir = ltrim($this->getMediaDir(), '/');

        // prepare source/target filename
        $targetFilename = sprintf('%s/%s', $mediaDir, $trimmedFilename);

        // query whether or not the image file to be deleted is available
        if (!$this->getFilesystemAdapter()->isFile($targetFilename)) {
            throw new \Exception(sprintf('Media file %s not available', $targetFilename));
        }

        // delte the image from the target directory
        $this->getFilesystemAdapter()->delete($targetFilename);
    }
public function deleteFile ( $ filename ) { // trim the leading /, if available $ trimmedFilename = ltrim ( $ filename , '/' ) ; $ mediaDir = ltrim ( $ this -> getMediaDir ( ) , '/' ) ; // prepare source/target filename $ targetFilename = sprintf ( '%s/%s' , $ mediaDir , $ trimmedFilename ) ; // query whether or not the image file to be deleted is available if ( ! $ this -> getFilesystemAdapter ( ) -> isFile ( $ targetFilename ) ) { throw new \ Exception ( sprintf ( 'Media file %s not available' , $ targetFilename ) ) ; } // delte the image from the target directory $ this -> getFilesystemAdapter ( ) -> delete ( $ targetFilename ) ; }
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 .