SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast FSan's Avatar
    Join Date
    Dec 2005
    Location
    San Martin de los Andes, Patagonia Argentina
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bulk image uploading

    Hi all.

    I have this new client who does dog-sled rides. He gives his customers a cd with pics of the ride from his digital camera.

    I thought it'd be a good idea to create image galleries on the website and uploading the pics there instead of giving away the cd (to increase traffic among other things).

    Wanting to make the image upload process as easy as possible I thought of gzipping all the image files, uploading just the gzip and getting the server to manage the gallery generation.

    Is this a good idea? Am I overcomplicating things or will I end up overloading the server?

    Could anyone share any ideas regarding the general flow of the script?

    I'm just starting to 'cook' this and I never used zlib or anything like it before. Comments will be much appreciated.

    Thanks!

  2. #2
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, sounds a lot like Gallery. Perhaps you can tweak or theme it to your liking and save some valuable time while still delivering a valuable service? ($weet!)

    As far as gzip-ing is concerned, it can greatly simplify downloading groups of files but for uploading files which are already compressed (JPEG) it may not be a great time saver since it creates extra steps for each upload. (creating and unzipping archives takes time on each end which is unlikely to be offset by the compression)

  3. #3
    SitePoint Enthusiast FSan's Avatar
    Join Date
    Dec 2005
    Location
    San Martin de los Andes, Patagonia Argentina
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for you comments Trent. Yes, I had been checking Gallery out but really don't need something that feature-full.

    I was also checking this post http://www.sitepoint.com/forums/showthread.php?t=404494

    I haven't decided which route to take yet. Gallery seems a good choice but I'm still thinking of just shoving a zip file or bulk of some sort up the server and deal with it there which would probably be easier to integrate with my existing CMS.

    Still searching. Ideas welcome.

  4. #4
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also offer multiple upload fields on one form. Means a little extra work client side, but a lot less work server side.
    PHP | MySQL | (X)HTML | CSS

  5. #5
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,358
    Mentioned
    80 Post(s)
    Tagged
    3 Thread(s)
    If you are uploading a load of images I would just go for resizing them etc. on the PC.

    Create a folder for each new gallery and upload them via FTP. You can get some programs / windows batch files where the user right click on the items and they get uploaded. One is called sendtoftp and another ShellFTP; you could set these up for the site owner.

    It then depends how clever you want to get with the gallery, in the past I wrote some code that read a directory for all the directorys in it, reads the last uploaded image, last taken image from EXIF data or random image in each directory and displayed an index of the directorys. When you selected a directory it showed all the images in the directory in a table.
    I have also made it so each image was associated with a text file that you could add some comments.

    Or you could go with a standard off the shelf gallery

    It all depends on what you want.

    One thing about using a form - on my server setup anyway - was that I could only upload a maximum of 3 or 4 images at a time.

    A lot of these large gallery scripts is that they are to large and most of the function you will never use.

    Here is a bit of code I have been working on that you could easily modify; a sample of use at the bottom.
    PHP Code:
    <?php
    function image_table($directory$border$row$cell$ignore_array){
     
    // Start the table 
        
    echo "<table border=\"".$cell."\">\n";

    // The array that will store the files
        
    $files = array();
        
    // Read the contents of the directory    
        
    $read $directory;
        
    $mydirectory opendir($read);
        while((
    $item readdir($mydirectory)) !== FALSE)
        {
        
    // Ignore items  - sent from main code  
        
    if(!in_array($item,$ignore_array) && is_file"$read/$item))
        
    // Build the array of images    
        
    $files[]=$item
        }
        
    closedir$mydirectory );

    // Count the number of files    
        
    $indexCount count$files );
        
    // Setup the table layout
        
    $column=1;

    // Loop through the array adding the images
        
    for ( $i=0$i<$indexCount$i++ )
        {    

    // If the column value is one add a table row tag    
        
    if ( $column == )
        {
        echo 
    "<tr>";
        }

    // Strip the extension from the file name for use in the table    
        
    $file_name[$i]=substr($files[$i], 0, -4);
        
    // Put the images into a table cell with the image name underneath
        
    echo "<td align=\"center\"><img border=\"".$border."\" src=\"".$read."/".$files[$i]."\" height=\"100\"><br><p>".$file_name[$i]."</p></td>\n";

    // Add 1 to the column variable    
        
    $column++;
      
    // End the row if the images reach the target number and set column variable back to 1
        
    if ( $column == $row )
        {
        echo 
    "</tr>\n";
        
    $column=1;
        }
    // End the loop to  generate the table
        
    }
        echo 
    "</table>";
    }

    // USE: image_table('directory', 'image border size', 'Amount of the images in a row ( 5 = 4 images in the row )', 'table cell border size', 'array of items to ignore - directorys will be ignored by default' );
        
    $ignore_array = array ( '.''..''Thumbs.db' );
        
    image_table('art''0''5''1'$ignore_array);
    ?>
    P.S.
    You may be able to use the FTP function built into php and a form - I keep meaning to look into that !
    Last edited by Rubble; Apr 10, 2007 at 03:37. Reason: Added P.S.

  6. #6
    SitePoint Enthusiast FSan's Avatar
    Join Date
    Dec 2005
    Location
    San Martin de los Andes, Patagonia Argentina
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot Rubble. I hadn't thought of built in ftp. You were really helpful.
    I'm really not in a hurry with this so I'll keep researching. My main goal is to make uploading as hassle-free as possible for the user.

    I've pretty much narrowed my choices to http://gallery.menalto.com/ and your ideas. Thanks again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •