473,216 Members | 1,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Reading Folders

Hiya,

If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database rather
than having to manually input the names into the database

Any help would be great.

Cheers.

DaRemedy
Jul 17 '05 #1
11 7569
On Mon, 8 Nov 2004 19:32:10 +0000 (UTC), "DaRemedy"
<de******@btinternet.com.nospam> wrote:
If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database rather
than having to manually input the names into the database


opendir, loop of readdir + mysql_query, closedir.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
DaRemedy wrote:
If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database
rather than having to manually input the names into the database


http://www.php.net/opendir & http://www.php.net/readdir

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #3
DaRemedy wrote:
Hiya,

If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database rather
than having to manually input the names into the database


One thing you should remember if the filenames col of your MySQL is
going to be unique:

The Linux filesystem is case-sensitive, so FILENAME.gif FileName.gif,
and and filename.gif can all exist in the same directory at once. MySQL
text fields however aren't case sensitive in the same way, so you
couldn't have all three stored in the same unique field in separate rows.
--
Matt Bradley
Put smarties tubes on cats legs make them walk like robots.
Jul 17 '05 #4
the previous replies say it all.. however it might be nice to
automatically create thumbnails as well with GDlib, while you're looping
through the files:

http://nl3.php.net/manual/en/functio...yresampled.php (nice)
or
http://nl3.php.net/manual/en/functio...opyresized.php (crappy)

DaRemedy wrote:
Hiya,

If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so that
everytime i take a load of pics, all I would have to do is get PHP to read
the contents of the folder and add the filenames to a MySQL database rather
than having to manually input the names into the database

Any help would be great.

Cheers.

DaRemedy

Jul 17 '05 #5
Wow,

Thanks guys, I really appreciate all your help.

Even though I am a total newb, I will read up and try out the suggestions
posted. What I am trying to do is create an online image gallery like the
one used on the Bungie site located at
http://www.bungie.net/Games/Halo2/pa...on=Main&page=1
On the site, they have a list of categories such as renders, concept art
etc, which displays each image thumbnails when clicked upon. These
thumbnails are linked to a popup window displaying the larger image. I know
that this is a simple image gallery, but I don't even know where to begin :(

Thanks once again, guys.

DaRemedy.
"Harrie Verveer" <ne********************@harrieverveer.com> wrote in message
news:kI********************@zeelandnet.nl...
the previous replies say it all.. however it might be nice to
automatically create thumbnails as well with GDlib, while you're looping
through the files:

http://nl3.php.net/manual/en/functio...yresampled.php (nice)
or
http://nl3.php.net/manual/en/functio...opyresized.php (crappy)

DaRemedy wrote:
Hiya,

If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to
a
MySQL database?

What I am trying to do is create an image gallery using PHP/MySQL, so
that
everytime i take a load of pics, all I would have to do is get PHP to
read
the contents of the folder and add the filenames to a MySQL database
rather
than having to manually input the names into the database

Any help would be great.

Cheers.

DaRemedy


Jul 17 '05 #6
Take it step by step. First try to just list the image names in a dir
with an echo(). Then, try putting those filenames in the database. After
that, try creating one thumbnail with imagecopyresampled or
imagecopyresized - then add it in your loop. Make something that reads
your database table. First, just let the script display the fetched
filenames. Then add an <IMG> tag around it, etc. etc. Don't build the
entire application at once - especially when you just started in PHP (or
any other programming langage), just take it step-by-step.

DaRemedy wrote:
I know
that this is a simple image gallery, but I don't even know where to begin :(

Jul 17 '05 #7
that's correct - a solution might be adding the filenames encrypted into
the database?
The Linux filesystem is case-sensitive, so FILENAME.gif FileName.gif,
and and filename.gif can all exist in the same directory at once. MySQL
text fields however aren't case sensitive in the same way, so you
couldn't have all three stored in the same unique field in separate rows.

Jul 17 '05 #8
Thankyou very much, Harrie

Your help and advice are greatly appreciated, my friend.

I will try building the application in step-by-step stages and will let you
know how it goes.

Take Care.

DaRemedy.

"Harrie Verveer" <ne********************@harrieverveer.com> wrote in message
news:TJ********************@zeelandnet.nl...
Take it step by step. First try to just list the image names in a dir with
an echo(). Then, try putting those filenames in the database. After that,
try creating one thumbnail with imagecopyresampled or imagecopyresized -
then add it in your loop. Make something that reads your database table.
First, just let the script display the fetched filenames. Then add an
<IMG> tag around it, etc. etc. Don't build the entire application at
once - especially when you just started in PHP (or any other programming
langage), just take it step-by-step.

DaRemedy wrote:
I know that this is a simple image gallery, but I don't even know where
to begin :(

Jul 17 '05 #9
I noticed that Message-ID:
<41**********************@news.dial.pipex.com> from DaRemedy contained
the following:

I will try building the application in step-by-step stages and will let you
know how it goes.


Try this to get you going. You can see the result at
http://www.ckdog.co.uk/dev/listfiles.php

<html>
<body>

<?php
//insert relative path to directory below
$path="../path/to/directory/";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if(strpos($file,"jpg")!=false)
{
echo "<span style=\"float: left;padding: 5;margin-bottom
5;\"><img src=\"$path$file\"></span>\n";}
}

}
?>
</body></html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #10
On Tue, 09 Nov 2004 14:07:08 +0100, Harrie Verveer
<ne********************@harrieverveer.com> wrote:
The Linux filesystem is case-sensitive, so FILENAME.gif FileName.gif,
and and filename.gif can all exist in the same directory at once. MySQL
text fields however aren't case sensitive in the same way, so you
couldn't have all three stored in the same unique field in separate rows.


that's correct - a solution might be adding the filenames encrypted into
the database?


Don't trash the data, fix the database. MySQL has perfectly good
case-sensitive types.

http://dev.mysql.com/doc/mysql/en/St..._overview.html

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #11
method
6
Hi guys. could any one tell me how i can reead sub directory content using php and then write it to mysql database ? I be happy if an expert show me how .Thanks
Feb 9 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nancy Kafer | last post by:
I am trying to write a program that will log into a user's mailbox and loop through all folders looking for certain file extensions. Can anyone tell me what methods I need to use to retrieve the...
1
by: Mike Preston | last post by:
Has anybody used something like DSOFile to read and write properties of folders on an NTFS drive? This will be for my own use, so things like security don't really matter to the project at hand. ...
4
by: Yavuz Bogazci | last post by:
Hi, has someone a C# oder VB.Net Class for reading Outlook Express .dbx Files. I need a sample how i can read the content of a .dbx File and show the Emails with C# or Vb.Net. thanks Yavuz...
1
by: Andrew Gomes | last post by:
Does anyone know if there is an alternative to reading Exchange 2003 public folders with WMI? I am using WMI in VB.NET to read a list of public folders on an Exchange 2003 server. My problem is...
2
by: al jones | last post by:
I'm trying to get something to work here and not having much luck. I can take the sledgehammer approach (read each line, parse for the tab sepertor, put each part in it's respective element) but...
2
by: beeswax | last post by:
Hi, Does anyone knows how to read e-mails from a specific folders in outlook? I only found out how to read the mails from the inbox folder and how to list all available folder. I just don't...
2
by: doublemaster007 | last post by:
Hi How to read binary files in MAC OS? FILE *readFile = fopen("filename", "rb"); then reading it like this: count=fread(readBuffer, sizeof(char), bufferSize, readFile)
1
by: PythonUser1 | last post by:
Hi, I am using RubyZip and want to read a folder and keep all the sub folders and files and create a .zip file. Please give me ant sample code on the same. I tried to read a file like this...
32
by: ramesh54 | last post by:
Hello All, I have a small problem in reading the filename of a file. I would like to have a script which could read my file and create the respective folders, The file to be read is as follows...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.