How to get the full file path in Zend

I want to delete a file. I know the relative path from the shared directory. Are there any zend-way methods to delete a file? I think the definition of BASE_DIR in index.php is wrong.

+3
source share
2 answers

Assuming a directory structure as follows:

/application/
/public/
  /files
    file1

path to file1equal

$path = realpath(APPLICATION_PATH . '/../public/files/file1')

then you can perform any string operations on this path (for example, check the length of your relative path and subtract it from the end $path)

APPLICATION_PATHalready defined in index.phpon Zend_Application.

Then you can delete the file with unlink.

This is just a hunch. You did not write how the file is stored.

+7
source

, Zend Framework 2 , APPLICATION_PATH, ROOT_PATH! , - (index.php):

/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));

, ZF2, , / .

+2

Source: https://habr.com/ru/post/1776315/


All Articles