Ok, so I have a folder called pictures that has around 100 images of sunset. I use glob to create an array of all of those images. Then, I write those to a text file for later use, but my code isn't working and I don't know why. When I run this code on a webpage, nothing happens, even the "echo $image" doesn't work and my text file doesn't get updated either. Does anyone know what I'm doing wrong? Also, I started php last week so I'm very new to this.
<?php
$directory = "C:\Users\Owner\Desktop\SunsetDirectory\pictures";
$images = glob($directory . "/*.jpg");
$myfile = fopen("C:\Users\Owner\Documents\SunsetWebsite\sunsettext.txt", "w") or die("Unable to open file!");
foreach($images as $image)
{
echo $image;
fwrite($myfile, $image);
}
fclose($myfile);
?>
test
, it prints it out, I don't know why nothing is happening because i do believe my code should work unless I'm missing something. – Bobby.lock Oct 19 '20 at 19:55