listing files from directorwy with php
|
||||||||||||||||||
Iam at parent directory ,in this image and fliephp files are
there, from this place , I want to read whats the files are there in he image
director, and before this parent/images/1.jpg
|
||||||||||||||||||
file.php
|
||||||||||||||||||
every folder consists some files , called directory
|
||||||||||||||||||
open dir - uysing this we can open the directory and ready to
execute
|
||||||||||||||||||
read dir - using this we can read each and every element in
directory
|
||||||||||||||||||
how to print the names of the images inside the directory with
extension
|
||||||||||||||||||
</php
|
images/ or second argument is slash
|
|||||||||||||||||
$directory = 'images';
|
variable name created
|
|||||||||||||||||
if (@opendir($directory. '/') {
|
used @ for , if this fails, it wil print some error commands, to
remove that use @
|
|||||||||||||||||
echo 'Looking inside <strong' .$directory .'</strong>
.: <br>';
|
||||||||||||||||||
}
|
looking inside the images
|
|||||||||||||||||
else {
|
it will print we eare looking , it the files in not there, it
shows cannot be opened
|
|||||||||||||||||
echo $Director. 'cannot be opened';
|
||||||||||||||||||
}
|
||||||||||||||||||
how to print with directory two dots of the images in directory
|
||||||||||||||||||
</php
|
||||||||||||||||||
$directory = 'images';
|
||||||||||||||||||
if (@$folder = opendir($directory. '/') {
|
takes the directory data to folde variable
|
|||||||||||||||||
echo 'Looking inside <strong' .$directory .'</strong>
.: <br>';
|
prints the data insde the director
|
|||||||||||||||||
while ($file = readdir ($folder){
|
with readdir- refers each and every file in that directory
|
|||||||||||||||||
echo $file .'<br>';
|
each file prints and go t o initial
|
|||||||||||||||||
}
|
||||||||||||||||||
else {
|
imag
|
|||||||||||||||||
echo $Director. 'cannot be opened';
|
if not there , can not be opened
|
|||||||||||||||||
}
|
image
|
|||||||||||||||||
it wil print with directory dots also
|
||||||||||||||||||
how to print without directory two dots of the images in directory
|
||||||||||||||||||
</php
|
||||||||||||||||||
$directory = 'images';
|
images string went to directory variable
|
|||||||||||||||||
if (@$folder = opendir($directory. '/') {
|
it will open the images directory means ready to execute
|
|||||||||||||||||
echo 'Looking inside <strong' .$directory .'</strong>
.: <br>';
|
prints looking insde the images
|
|||||||||||||||||
while ($file = readdir ($folder0){
|
next exeute next thing , go to each and every line in directory
|
|||||||||||||||||
if($file !='.' &&
$file != '..'){
|
it wll chek if it is not equal,, then prints the image shows
with change in width
|
|||||||||||||||||
echo '<img src = "'.$directory.'/'.$file.'" width
='300" heiaght= "300"><br><br>';
|
||||||||||||||||||
}
|
||||||||||||||||||
}
|
||||||||||||||||||
else {
|
||||||||||||||||||
echo $Director. 'cannot be opened';
|
||||||||||||||||||
}
|
||||||||||||||||||
|
||||||||||||||||||
Tuesday, 9 June 2020
listing files from directorwy with php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment