Hello!
I'm fairly new to PHP and I've been trying to "automate" my gallery, so when i FTP images in certain folders, the script can use those images and put them into the gallery automatically.
Here is the code:
<?php
$directory = "/images";
/* for testing only */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
$test = glob($directory . "*.jpg");
var_dump($test);
foreach (glob($directory . "*.jpg") as $filename) {
echo '<a href="' . $directory . $filename . '">
<img src="' . $directory . $filename . '" width="500" height="333" title="' . $filename . ' /></a>';
}
?>
I've run into 3 problems:
1. When i specify the directory path like this: $directory = "../images/NY/" it doesn't work but in the html file it works perfectly. The script is located in "root/gallery" , and the images are located in "root/images/NY". But when i move the script to "root/images" and specify the path like this $directory = "NY/" it works like a charm.
2. Instead of giving me the following code for each image respectively:
<a href="NY/image1.jpg">
<img src="NY/image1.jpg" width="500" height="333" title="image1" /></a>
i get this part first for every image respectively:
[0]=>
string(37) "NY/image1.jpg"
How can i get rid of that part?
and after that this:
<a href="NY/NY/image1.jpg">
<img src="NY/NY/image1.jpg" width="500" height="333" title="NY/image1.jpg /></a>
Why does the $filename write out both the path of the folder and the name of the image?
3. How can i avoid the problem of special characters? I'm in Croatia, and letters like č, ć, đ, š, ž are frequently used, and I've used those in naming the files and folders in which i keep the images. For the sake of someone that will ( i hope at least ) help me, I've used NY and image1 as names, but in reality the names consist of the special characters. So is there a way to make php read those normally or do i have to use the standard ones?
Thank you very much in advance!