PHP image randomization problems

Discussion in 'PHP' started by derek34, Jan 1, 2008.

  1. #1
    Hi
    I am having trouble getting a simple image randomization script to work. When I test it on my own computer it works fine.
    However, when I upload all the photos and script to my web server, it does not work.
    Any idea why it won't work on the web server?
    Here's the script:
    
    <?php
    
    $images = array(
        
    	'DSC_0097.jpg',
            'DSC_098.jpg',
            '..........' //rest of images
    );
    
    header('Content-Type: image/jpeg');
    readfile($images[array_rand($images)]);
    
    ?>
    
    PHP:
    That is an external script that gets called like this:
    
    <img src="images/lanoct/image.php" />
    
    PHP:
    Any help is appreciated as always.
    Thanks
    - Derek
     
    derek34, Jan 1, 2008 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I guess that you are testing the script on windows and uploading it to a linux server !

    Check the images directories/files permissions
     
    selling vcc, Jan 1, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Are the images in images/lanoct/??

    And what do you see when you directly browse to the image.php file? If it's blank, see the source code of it (right click and "view source code"), and see if you get a specific error there.
     
    nico_swd, Jan 2, 2008 IP