You may also use blobs to store the images in the database. That may
induce some major slowdown for large numbers of images. I would suggest
going with a directory structure on the filesystem, managing the
structure from PHP and allowing no more that 100 images per directory.
For example:
----------------------
<?
// Globals
$image_path="/var/www/html/pal/external_images";
$count_limit=100;
// main
$dir=0;
while (is_dir($image_path.$dir)) {
$dir++;
}
if ($dir) {
// Going back to the last existing directory
$dir--;
} else {
// We don't even have the first directory, so we'll create it
mkdir($image_path."0");
}
$im=0;
while(is_file($image_path.$dir.$im)) {
$im++;
}
// We started counting from 0
if ($im>($count_limit-1)) {
$dir++;
mkdir($image_path.$dir);
$im=0;
}
// Ok, got the final image path - let's store it
$image_path.=$dir.$im;
// The file upload field is expected to be "image"
if (is_uploaded_file($_POST["image"]) {
copy($_POST["image"],$image_path)
}
mysql_run_query("insert into entries set image_path=\"$dir$im\"");
?>
----------------------
This is obviously just the skeleton of the upload page, but I hope it's
explicit enough to start things going...
Bogdan
Jason Soza wrote:
>Couldn't you just add a column to your MySQL table where the image name
>would be stored, then when you display your query results in your
>script, just put something like:
>
>echo "<img src=\"path/to/your/images/$imagename\">";
>
>Seems easy enough.
>
>Jason Soza
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php