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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.