TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Directory Control Panel (Images Mainly) (http://www.talkphp.com/absolute-beginners/1339-directory-control-panel-images-mainly.html)

TeIXe 10-25-2007 01:39 PM

Directory Control Panel (Images Mainly)
 
Hi,

Is there anyway that I could display the images in a directory (for example uploads) as a thumbnail and then a few links to delete it or rename each image?

Sort of like a Image Back End Control Panel, I suppose.

Any help would be greatly appreciated.

Gareth.

bluesaga 10-25-2007 01:51 PM

Well the management of the uploads is easy:

http://uk3.php.net/manual/en/ref.filesystem.php

See the file system functions, and use them to list and rename, delete etc the files. The file functions are a good place to start with, but it would be worth you adding mysql support for management of the files eventually.

Karl 10-25-2007 02:44 PM

Here's a bit of code for the image part. It could be cleaned up a bit better, but it's enough to get your started and it works (currently only with jpeg)

PHP Code:


<?php

$szImagesDir 
'images/';
$szThumbsDir 'images/thumbs/';

foreach (
glob($szImagesDir '*.{jpg,JPG}'GLOB_BRACE) as $szImagePath)
{
    
$aImagePathParts explode('/'$szImagePath);
    
$szFileName end($aImagePathParts);

    if (!
file_exists($szThumbsDir $szFileName))
    {
        
$pImageHandle imagecreatefromjpeg($szImagePath);

        if (!
$pImageHandle)
        {
            continue;
        }

        
$aSize getimagesize($szImagePath);
        
        
$pNewImageHandle imagecreatetruecolor(6464);
        
        
imagecopyresampled($pNewImageHandle$pImageHandle00006464$aSize[0], $aSize[1]);
        
        
imagejpeg($pNewImageHandle$szThumbsDir $szFileName);        
    }
    
    echo 
'<img src="' $szThumbsDir $szFileName '" />';
}

?>

Simply change the two directory paths at the top to point to your images and thumb folders. The thumbs folder is used to store thumbnails of each image - you'll need to create this.

Hope it helps.

TeIXe 11-02-2007 03:12 PM

Wow thank you; I completely missed your posts! :O


All times are GMT. The time now is 06:30 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0