php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74504 getimagesize fails with relative path
Submitted: 2017-04-26 22:03 UTC Modified: 2017-04-27 19:38 UTC
From: dpfender44 at gmail dot com Assigned:
Status: Not a bug Package: GetImageSize related
PHP Version: 7.1.4 OS: Windows
Private report: No CVE-ID: None
 [2017-04-26 22:03 UTC] dpfender44 at gmail dot com
Description:
------------
If the path to the image file is relative to current directory (up a level), the file cannot be found.  Only a path from the current level and downward will work or using a full path from the very top level.  There is nothing in the documentation to say that this should not work.

Test script:
---------------
// current working directory is w:/xxx/admin
// images are in w:/xxx/pics
$fpath = '../pics/img.jpg';
$x = getimagesize($fpath);
// CANNOT FIND THE FILE
$fpath = 'w:/xxx/pics/img.jpg';
$x = getimagesize($fpath);
// RESULT is GOOD


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-27 07:18 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-04-27 07:18 UTC] requinix@php.net
Works fine for me. Are you sure the working directory is what you think it is? You know it's not necessarily the same directory that the current executing script is in, right?

echo getcwd() . "/" . $fpath;
 [2017-04-27 19:31 UTC] dpfender44 at gmail dot com
-Status: Feedback +Status: Closed
 [2017-04-27 19:31 UTC] dpfender44 at gmail dot com
Sorry for the confusion.  A function of mine was called to scan for files and it resulted in the current working directory to be one level above the one where the script was initially started.  Using chdir() to reset the original directory after the scan fixed the problem.
 [2017-04-27 19:38 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 00:01:26 2019 UTC