Jump to content

photo album,need hints


freebsdntu

Recommended Posts

Hi guys,I am trying to write a very simple photo album, like the one on msn space.

I am planning to make use of both php and javascript, actually I would prefer to use more of js to handle client side operations.

What I am trying to do now as a start is to get all the image urls of a album folder on the server. I tried to store all the image urls into an array in server side php, the question is how do I pass the array to client side so that my javascript code can access it?

 

here is the php code I have written, just for reference.

<?php
class PhotoAlbum
{
    var $albumUrl; /*the url of the album*/
    var $size; /*totl number of images in the folder*/    

    /*class constructor*/
    function PhotoAlbum($albumUrl)
    {
        $this -> albumUrl = $albumUrl;
        $this -> size = 0;
    }

    /*function to get total number of photos in an album*/
    function getSize()
    {
        $this -> getImageUrls();
        return $this -> size;
    }

    /*function to store the urls of each image into an array and returns the array*/
    function getImageUrls()
    {
        $imageUrls = array();
        if (!($dir_handle = opendir($this -> albumUrl)))
            echo "cannot open directory '$this -> albumUrl'";
        while ($file = readdir($dir_handle))
        {
            $size = $size + 1;
            array_push(imageUrls,$file);
        }
        $this -> size = $size;
        return $imageUrls; 
    }

}
?>

 

Also I would love to hear better approaches regarding the design?

Link to comment
https://forums.phpfreaks.com/topic/81700-photo-albumneed-hints/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.