
SaranacLake
Members-
Posts
648 -
Joined
-
Last visited
Everything posted by SaranacLake
-
How did you know I use Xdebug?
-
Yes, I do happen to have Xdebug set up in NetBeans, but I haven't been using it for this particular issue..
-
Yeah, sorry, I didn't notice that the count was correct until trying several tests and then my eyes finally noticed that as I was searching for the issue.
-
Yeah, that is on to-do list putting this site together!
-
I just sorted my original photos/videos by type, and grabbed all of the photos (i.e. 600) and pasted them in my websites "images/" directory. When I re-ran things, it took a while, but it appears that all of the photos rendered on my web page. That is nearly 1 GB of photos!! I think my browser was choking on the extra video files and the sheer size of things? Of course if I create thumbnails that will make it much easier to load things! Still curious why var_dump( ) won't show more than 128 elements in the display even though it gives a proper count. All very interesting!
-
I think there are a couple of strange things going on here... - When I uncomment Var_dump() and exit(), I do see the array count is correct (e.g. 1,210) but the actual displayed array is stopping at 128 elements and then says "more elements..." at the bottom. - When I comment out var_dump() and exit() and run my web page, I see blanks for what appers to be 1,210 files, but I am only seeing photos for maybe 100 or so. (Maybe 128?) - I have movies from my phone intertwined with the JPG's. I can try deleting those out of my "images/" folder, but I suspect this is a browser or memory ssue since 1,210 X 1-2 MB is A LOT of memory usage!! - I need to learn how to make smaller thumbnails...
-
I have one sub-directory in the directory I point too, but it doesn't have that many photos in it. The fact that my array went to 127 makes me thing it is something predicatable since that is 128 elements in the array. (2^7=128) I dunno....
-
So what could the issue be? Does it have to do anything with the filesize? I have like 600 1-2MB photos in the directory. Am using my Mac for dev work.
-
Why does formatting get messed up with PHPFreaks [ code ] tags? (Was never an issue in the past...)
-
Here is my code... <?php $path = "../WORKSPACE/images/"; $files = array(); // Check for Directory. if (is_dir($path)){ // Open Directory-Handle. $handle = opendir($path); if($handle){ // Iterate through Directory items. // Return name of next item in Directory (i.e. File or Folder). while(($file = readdir($handle)) !== FALSE){ if($file != '.' && $file != '..' && preg_match("#^[^\.].*$#", $file)){ // Not Directory, Not Hidden File // Add to array. $files[] = $file; // Simple array. // $files[] = array($file); // Nested array. } } closedir($handle); } } var_dump($files); exit(); ?> By the way, thanks for trying to help last night, but I couldn't really follow your glob( ) example so I took the above approach which was easier for me.
-
Is there a limit to how many items can be stored in an array? My code looks in a directory of photos and writes the file names into the one-dimensional array. I just switched from my test folder to my actual photo folder - about 600 photos - and when I ran my script with var_dump enabled, my array only goes up to 128 items (0-127). I sure hope arrays aren't that wimpy?! Each photo is about 1-2MB in size, but since I am only storing the file name, I would expect that I could easily store thousands of elements in this array. What is going on?
-
..
-
Thanks for the code - might be handy if I go with a database solution. Um, @Barand, nothing is "easy" when you have been away from coding and database for 4-5 years (and are an old man) like me!! While you sample is useful - thanks - id does NOT cover all of the other things I need to do like creating a database in my DEV environment, writing code to read the DB and populate my PHP gallery, creating a PROD database on my server, migrating the DEV data to PROD, and don't forget data entry. If it was "easy", I wouldn't be griping here. Guess it will come down to how much time I have left - if any - at the end of this 4-day weekend. (Can't believe I spent my whole holiday building something for work for free?! Such is the addiction of a programmer with a problem to solve?!)
-
No, unfortunately what I need isn't in the metadata, but that is a good idea for future projects!
-
That's one option.
-
!== does not just mean "not TRUE" - It means "not identical". Now where is the "lack of understanding"? đ https://www.php.net/manual/en/function.readdir.php (see the "Warning" section.) https://www.php.net/maunal/en/lanuage.operators.comparison.php
-
Like many projects, this started small, and keeps growing! I am building a photo gallery and would now like to add labels/captions below each photo, HOWEVER, I really don't want to have to build a database and do all the related coding. (I know how, but its a PITA.) To display photos in the gallery, I read in files from my "images/" directory, store them in a simple array, and then iterate through the array to display the thumbnails in a gallery. I am wondering if there would be an easy way that I could merge photo metadata (e.g. a brief caption) with my array or something like that? If I could type up the file names and a brief description/caption in a Text File or Spreadsheet and then somehow slurp that into my code and merge it with my array or something like that, then I would be willing to type up captions. (This is for like 600 photos which is why I don't want to do a database as data entry in phpMyAdmin is a PITA!) Any suggestions how I could do this and add a "cherry on the top" of this mini project I am doing for my co-workers? Thanks!
-
That's why you are a "guru"!! đ Is there a cleaner way to write this... while (($file = readdir($opendirectory)) !== false){ As you can see, I tried to break that up into two parts, because I hate the idea of doing an *assignment* and a *logical comparison* all in one statement. Unfortunately I broke the logic as you pointed out.
-
Why does this code seem to run okay... $directory = "images/"; // Open a directory, and read its contents if (is_dir($directory)){ if ($opendirectory = opendir($directory)){ while (($file = readdir($opendirectory)) !== false){ echo "filename:" . $file . "<br>"; } closedir($opendirectory); } } And this code sends my computer into an infinite loop... $directory = "images/"; if (is_dir($directory)){ $opendirectory = opendir($directory); if($opendirectory){ $file = readdir($opendirectory); while($file !== FALSE){ echo $file . "<br>"; } closedir($opendirectory); } }
-
I am still not understanding how to tell glob() where to look for files? Is there a more robust/better way to do this than using glob()?
-
I did read it and at first read it just seemed like a regex. I looked at the link again and it sorta makes sense, and am trying it now. I recall seeing this done in the past and you had to use all of these file commands which is why I was confused by his answer. Is glob supported by all versions of PHP? Are there other ways to do this? (It sounds like it lacks leveraging regex, which probably doesn't matter in my immediate need, but still.
-
Not sure how that function would help. I need help figuring out how to tell PHP to iterate through a given folder and read the file names.
-
I have a directory full of pictures that I would like to display in a gallery. Originally I was going to write HTML like this... <li> <img src=/photos/img_001.jpg"> </li> And then simply copy and paste that for the number of photos I have, and then tweak the code to: img_002.jpg, img_003.jpg, and so on. I guess that is silly considering that I have over 500 photos to display! How could I use PHP to go to my /photos/ directory, scan all of the files in that directory, and then grab the file name so I could automate this process? Sorry, but I haven't written PHP in several years so all of this escapes me! âšī¸
-
I could do that, but first of all, that would require that I have everyone's email addresses. (I am going to send out an email from work to our work distribution list, but I suspect people will view this from home - if they are smart they won't access my website from work!) And as far as passwords, if I want people to set their own password then you basically have a registration system. I know how to do that, but don't want to spend that much time coding things. I take security very seriously, but it doesn't seem that bad to share a password with co-workers for temporary access. Of course I wouldn't do that with a website like this or an e-commerce site, but it seems like a reasonable approach, or do you think I'm way off here? Also, since you recommended just using .htaccess, that would be the same issue of "lax" security, right?
-
What is a better alternative?