public function delete($name)
    {
        $this->loadModel('Field.FieldInstances');
        $instance = $this->_getInstance($name);

        if ($instance && !empty($this->request->query['file'])) {
            $file = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}", DS);
            $file = new File($file);
            $file->delete();
        }

        $response = '';
        $this->viewBuilder()->layout('ajax');
        $this->title(__d('field', 'Delete File'));
        $this->set(compact('response'));
    }
public function delete($name)
    {
        $this->loadModel('Field.FieldInstances');
        $instance = $this->_getInstance($name);

        if ($instance && !empty($this->request->query['file'])) {
            $file = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}", DS);
            $file = new File($file);
            $file->delete();
        }

        $response = '';
        $this->viewBuilder()->layout('ajax');
        $this->title(__d('field', 'Delete File'));
        $this->set(compact('response'));
    }
public function delete ( $ name ) { $ this -> loadModel ( 'Field.FieldInstances' ) ; $ instance = $ this -> _getInstance ( $ name ) ; if ( $ instance && ! empty ( $ this -> request -> query [ 'file' ] ) ) { $ file = normalizePath ( WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}" , DS ) ; $ file = new File ( $ file ) ; $ file -> delete ( ) ; } $ response = '' ; $ this -> viewBuilder ( ) -> layout ( 'ajax' ) ; $ this -> title ( __d ( 'field' , 'Delete File' ) ) ; $ this -> set ( compact ( 'response' ) ) ; }
Deletes a file for the given FileField instance.

File name must be passes as `file` GET parameter.

@param string $name EAV attribute name
@return void
@throws \Cake\Network\Exception\NotFoundException When invalid attribute name
is given
Deletes a file for the given FileField instance .