I'm currently creating a website as part of a high school internship for a professor as a university.
Since he is constantly uploading new assignments, I am wondering if there is a way that I can php
or JavaScript
to automatically add files inside the webpage.
To go into description of my concept, there is a set file structure for the professor's website. The website correlates with that file structure but every time he adds a file he has to go into the code and link it.
I know this would be easy with Dreamweaver
, but I want to make the process speedy for him. I want to have it so that he adds a file to the structure and the website automatically adds the name of the file within the webpage and makes a link to download it. I know nothing about PHP
but I am familiar with JavaScript
, just not with integrating it into HTML
.
Check the readdir function for php.
//Example #2 List all entries in the current directory and strip out . and ..
<?php
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry\n";
}
}
closedir($handle);
}
?>
Now you could change the opendir('.')
part to match any directory available to the webserver. And instead of just echo you can output htmlcode that links to the file.