Accesing an image for a subdomain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Accesing an image for a subdomain

Post by Rovas »

I have a server that a site domain and 2 subdomains, the PHP code plus the rest of the files used to "make" sits in a single directory called Core.
The problem is that: a script that reads and outputs images from Core doesn' t work in the subdomains. None of the error messages put in the file appear when I call for the file. I read about how the subdomains consider the absolute paths as starting from their directories, only links to other domains or subdomains work but I can use that.
The script is a simple one:

Code: Select all

 
         trace(__FILE__);
    if(!isset($_GET['file'])) {echo ( 'missing param file');}
    $path=$_SERVER['DOCUMENT_ROOT']'/img/'.$_GET['file'];
        // the onlyext is a function that extracts the extension from a given path
    header ("Content-Type:image/".onlyext($path));
    $msg='Canget. File not found:'.$path;   
    if (!is_file($path)) echo ( "$path file not found in canget." );
    $file_extension = onlyext($path);
        switch( $file_extension ) {
             case "php":
             case "py":
             echo ("Try to get a file of $file_extension type is not permitted");   
             break;
        }
    readfile($path);
 
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Accesing an image for a subdomain

Post by Benjamin »

duplicate thread: viewtopic.php?f=1&t=85226
Post Reply