In PHP, after assigning a file pointer resource to a variable with fopen(), how can I get the file name from the variable?

前端 未结 3 459
自闭症患者
自闭症患者 2021-01-21 01:42

For example:

$file = fopen(\"File.txt\", \"r\");
$filename = $file->basename;

if there was a method like basename for file objects (file poi

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 02:11

    I came to this page while trying to find out the filename that PHP's tmpfile() function had created - it returns a pointer. I wanted to use it to create a file I could use with some Unix commands. In the end I used tempnam(realpath(sys_get_temp_dir()), "piclib_"); instead.

提交回复
热议问题