This is a migrated thread and some comments may be shown as answers.

realpath(dirname(__FILE__) on IIS server

1 Answer 39 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Paweł Kasztelan
Top achievements
Rank 2
Paweł Kasztelan asked on 08 Jul 2013, 01:58 PM
Welcome. I have a problem with realpath (dirname (__FILE__) on IIS running PHP 5.4.
ImageBrowser.php returns the wrong path by which the file generates error and does not display the file or thumbnail.
The system CentosOS + Apache ImageBrowser.php works fine, but the client does not want to be at home in addition linux.

[08-Jul-2013 22:03:04 Europe/Warsaw] PHP Warning:  Missing argument 2 for ImageBrowser::setImageHeaders(), called in C:\IIS\8083\public\imagebrowser\ImageBrowser.php on line 238 and defined in C:\IIS\8083\public\imagebrowser\ImageBrowser.php on line 204
[08-Jul-2013 22:03:04 Europe/Warsaw] PHP Notice:  Undefined variable: type in C:\IIS\8083\public\imagebrowser\ImageBrowser.php on line 205

1 Answer, 1 is accepted

Sort by
0
Paweł Kasztelan
Top achievements
Rank 2
answered on 09 Jul 2013, 09:03 AM
Problem is solved. In the attachment corrected code.

public function basePath() {
 
      if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
          return $this->normalize($_SERVER["DOCUMENT_ROOT"] . "\\imagebrowser" . $this->contentPath);
      } else {
          $content_path = str_replace("\\", "/", $this->contentPath);
          return $this->normalize(realpath(dirname(__FILE__) . $content_path));
      }
  }
public function getThumbnail($path) {
(...)
        $this->setImageHeaders($path, $image->getType(), FALSE);
(...)
 
    }
public function setImageHeaders($path, $type, $size = TRUE) {
(...)
        if ($size == TRUE) {
            $size = filesize($path);
            header("Content-Length: " . $size);
        }
(...)
    }

I made the modification provides a path for IIS and Apache. I know that this is temporary, but the problem was solved with the transmission of image size and realpath () under IIS.





Tags
Editor
Asked by
Paweł Kasztelan
Top achievements
Rank 2
Answers by
Paweł Kasztelan
Top achievements
Rank 2
Share this question
or