views:

16

answers:

2

Hi This is a bit of a shot int he dark, but i dont even know how to google this to get started.

It's a very simple idea, but it would be extremely useful to designers and creatives for creating a scrapbook of sorts.

Baiscally i want to be able to drop an image I find on the internet onto an FTP folder which will just be a droplet on my desktop. The img gets uploaded to the folder. Then a Chron job on the server (I'm assuming that's what i'd need to set up?) checks to see if any new images are up, and then automatically creates code for the image and updates a single html file.

Really simple. But how would one go about that? PHP? I really dont know where to start as I'm only ok at a bit of jQuery and templating wordpress.

I mean maybe I could do this in wordpress too. That it just checks to see if any images are in the uploads folder and then creates a single post with no titles, comments and all that BS, but just inserts the image.

Any pointers would be immensely appreciated!

Best, Marc

A: 

Check out the function opendir in php :

http://us.php.net/opendir

You can just have a php page that does opendir on your ftp directory, then spits out an img tag for each .jpg file in the directory. This can read teh directory each time you open the page.

Zak
Really good to know about this too. Thanks a bunch Zak.
RGBK
+1  A: 

As I understand you correctly, you just want to have a page showing every image in a specific folder. That can easily be done with the glob() function:

foreach(glob('folder_with_images/*.jpg') as $image){
  echo '<img src="'.$image.'" alt="" />';
}

That's all. Just set up the "query" for the globas you need it. You don't need to do any kind of cronjob or update. It simply show all available images "live" as you open the page. I use glob() and not opendir() because you can use filter like "*.jpg" which you can't do with opendir().

When you have multiple file types, you can use scandir() and a if-statement:

foreach (scandir('folder_with_images/') as $image) { 
    if(substr($image, -3) == 'jpg' || substr($image, -3) == 'gif' || substr($image, -3) == 'png'){
        echo '<img src="'.$image.'" alt="" />';
    }
}
Kau-Boy
That sounds really good!I'm gonna try this now quick.God I love Stack Overflow.
RGBK
The proper way to indicate that is with an accepted answer and upvote.
Zak