realpath(dirname(__FILE__) on IIS server

2 posts, 0 answers
  1. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 08 Jul 2013 Link to this post

    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
  2. Paweł Kasztelan
    Paweł Kasztelan avatar
    17 posts
    Member since:
    Aug 2012

    Posted 09 Jul 2013 Link to this post

    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.





  3. UI for ASP.NET AJAX banner
Back to Top