still_motion Posted August 26, 2013 Share Posted August 26, 2013 Hello everyone, I am new to this forum (and php!) and searching for a solution to some functionality I am trying to implement. For our company intranet, our HR department has requested the ability to add folders and files to a directory on the website, and have them appear as links. I have gotten to the point where I am able to display a folder's contents as links on a webpage, but I would like to enable them to add new folders, and subfolders, and for php to "create" a page for each folder added. (It doesn't have to create actual physical pages, but just have links that go from one page to the next.) Directory: - HR folder - policy.pdf - HRForms Folder - form1.pdf - form2.pdf HR Webpage Shows (HR folder): - policy.pdf link - HR Forms (links to a new page) HR Forms wEBpage Shows (HRForms Folder): - form1.pdf - form2.pdf I have looked into recursive directory listing, but I am not sure if this will create the exact results I am looking for. The whole point of this is to allow users to add and remove folders, and php will automatically add pages/links for those folders on the website. The code I currently have below currently will only list the document contents of a specified folder as links: <h3>Human Resources </h3> <?php $dir = opendir('HRFolder/'); echo '<ul>'; while ($read = readdir($dir)) { if ($read!='.' && $read!='..') { $disp = $read; $pos = strrpos($read,"."); if($pos){ $disp = substr($read,0,$pos); } echo '<li><a href="HRFolder/'.$read.'">'.$disp.'</a></li>'; } } echo '</ul>'; closedir($dir); ?> I hope that I explained this well enough, any input would be highly appreciated!! Thanks! Ashley Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/ Share on other sites More sharing options...
Muddy_Funster Posted August 27, 2013 Share Posted August 27, 2013 I'll assume that you have been personally tasked with this because of financial restrictions. If that's wrong then you really should stop now and have a look into implimenting a propper WebDAV style section on your site for file/folder management. Anyway, have you looked into the glob() function at all? I think user submitted comment 3 looks like what your talking about. Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/#findComment-1446940 Share on other sites More sharing options...
still_motion Posted August 27, 2013 Author Share Posted August 27, 2013 Thanks for the suggestion! I will look into it. Actually, I am a front-end developer, but due to financial / employee limitations I am also tasked with trying to organize our mess of an Intranet. The employees currently drag and drop their files into drives that appear on their desktops that are shortcuts to sections of our internal website. Some of the pages have a somewhat functioning asp script that lists files in a directory. The problem is these people are not very technology-oriented and require a lot of assistance for even remotely complex tasks. I agree - this isn't a particularly secure method which has led to problems in the past, but I was trying to write a temporary solution in php while I work on implementing a WYSIWYG editor, user login and fixing our usergroup issues in the meantime. We have IIS to manage our servers and use active directory for establishing usergroups - but even so things have spiraled out of control to the point where pretty much anyone can edit anything. In terms of WebDav, do you have any recommendations? I am still new to server / security user file management, and would be curious to know what other advice people might have. In the mean time, I'll look at the glob() function and post back. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/#findComment-1446979 Share on other sites More sharing options...
Muddy_Funster Posted August 27, 2013 Share Posted August 27, 2013 To be honest, with your current systems (IIS, AD and ASP) I'm forced to confess that your best option in my opinion is - and I hate to say it - Sharepoint Server. It's Micro$oft's offering aimed at pretty much exactly what you are trying to do. And as nothing integrates with a microsoft product (i.e. Server OS) quite as well as another M$ product does it's the best option as far as I can see. It also has the benifit of being fairly intuative for people who are used to working in IIS so the learning curv should be minimal. Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/#findComment-1446990 Share on other sites More sharing options...
Andy-H Posted August 27, 2013 Share Posted August 27, 2013 There will almost definitely be something open-source to do this, have you tried sourceforge? or googling "PHP file management" (assuming it has to be in PHP), if I were implementing it myself, I would probably be using the SPL's recursivedirectoryiterator, PHP also exposes the underlying OS commands for file/directory deletion/creation/modification, see: chmod mkdir fopen fread fwrite file_put_contents Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/#findComment-1446994 Share on other sites More sharing options...
Muddy_Funster Posted August 27, 2013 Share Posted August 27, 2013 While I tend to champion Open Source mysqlf, from a buisness point of view it's not always the most cost effective route. When you factor in design, deployment, integration, setup and administration costs you can quite quickly find that you spent more on something that only comes with email support as and when the developer can be bothered to get back to you - not something that is apealing when the thing falls over and the people who pay your wages are staring at you expectantly waiting for you to make it work again. In the context of the origin information I don't think that an Open Source solution is the most desireable option. Quote Link to comment https://forums.phpfreaks.com/topic/281580-creating-links-to-pages-based-on-directory-contents/#findComment-1446999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.