TwelvestoneBack End

PHP file list


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Napalm
 
2010-04-21

I need to get a list of files in a directory, which then drops each filename into a html template, and then saves it as a new file.

So, image1.jpg that's in the directory is then added into a html template, and then saved as image1.htm

Is this possible?

Technomancer
 
2010-04-21

Yes

k

I'm pretty rushed at the moment...I'll try and knock up some example code for you tonight.

Stickman
 
2010-04-23

I know that Techno is very busy at the moment (chasing pigs again?) so here's something I knocked up very quickly:

<?php

$images_dir = 'images/'; $html_dir = './';

$template = '';

// Look for a .csv file $d = dir($images_dir); while (false !== ($entry = $d->read())) {

$path = $images_dir . $entry;
if( !is_dir( $path ) ){

    $pathinfo = pathinfo( $entry );

    $fp = fopen( $pathinfo[ 'filename' ] . '.html', 'w' );
    fwrite
    (
        $fp,
        str_replace
        (
            '[[image_path]]',
            $path,
            $template
        )
    );
    fclose( $fp );
}

}

?>

which shows the basic idea.

Napalm
 
2010-04-23

Thanks Stickman. I'll try that.

I'm trying to automate the creation of my businesscards and email stationary for clients - so I simply provide a client with a text file that they populate. So any mistakes in the businesscards' details is cause of client error.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneBack End

PHP file list