Darti Posted October 28, 2010 Share Posted October 28, 2010 Hi, I am looking to share out some of my files in a directory listing file management style. I want this to be presented to the web for users to access. An example of what i am looking for is attached. I dont want all the functions of a document management system, just maybe the ability to login and select files for download. Does anyone know of an easy way to present the files, with the ability to download individual files or a group of files by selecting them. The folder tree would be quite large so the presentation need to be lightweight. The host would be linux based, and can be presented in any format, php, javascript etc... FTP is not possible for the solution. Link to comment Share on other sites More sharing options...
0 Kami- Posted October 31, 2010 Share Posted October 31, 2010 There are plenty of PHP scripts available (unfortunately unable to provide link in case it breaks site rules here) - however some of the better ones even group the files into a zip file server-side so all user has to download is the one file :p Link to comment Share on other sites More sharing options...
0 GeeQ Posted October 31, 2010 Share Posted October 31, 2010 hey, i just made something similar but the thing is that it reads only the files from a selected directory... but can be useful to start with... it's a user profile page, that is public if you are logged in. it checks if the currently logged in user ($origuser) is the same as the one who's profile is shown ($user1) and then if it is, shows the private uploads otherwise only the public uploads. plus, if you are not logged in it tells you to do so. (i quickly cut out a few things so there can be errors in this but you can have the basics) <?php if (isset($_SESSION['user'])){ $user1 = $_GET[userid]; $origuser=$_SESSION['user']; echo '<div id="leftcolumn"><div id="mainpage">'; echo '<span class="title_txt">Public files</span><br/><br/>'; echo '<table width="370" border="0" id="hor-minimalist-b">'; echo '<thead>'; echo '<tr>'; echo '<th scope="col" align="left">Filename</th>'; echo '<th scope="col"></th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; if ($handle = opendir('uploads/'.$user1)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $icon = ShowFileIcon($file); $listitem='<tr><td width="358" align="left" valign="middle"><img src="images/icons/' .$icon. '" border="0" width="18" align="absmiddle"/> <a href="uploads/'.$user1.'/'.$file.'" title="Download '.$file.'">'.$file.'</a></td>'; echo $listitem; if ($user1 == $origuser ){ echo '<td align="center" valign="middle"><a href="deletefile.php?file='.$user1.'/'.$file.'&userid='.$user1.'"><img src="images/delete.png" width="12" height="12" border="0" align="absmiddle" title="Delete '.$file.'"/></a></td>'; } else { echo '<td align="center" valign="middle"></td>'; } echo '<tr/>'; } } echo '</tbody></table>'; } closedir($handle); if ($user1 == $origuser ){ echo '<br/><a href="uploadpublicfile.php?userid='.$user1.'"><img src="images/public_folder.png" border="0" width="24" height="24" align="absmiddle"/></a>'; echo ' <a href="uploadpublicfile.php?userid='.$user1.'">Upload file to the public folder</a>'; } if ($user1 == $origuser ){ echo '<br/><br/><span class="title_txt">Private files</span><br/><br/>'; echo '<table width="370" border="0" id="hor-minimalist-b">'; echo '<thead>'; echo '<tr>'; echo '<th scope="col" align="left">Filename</th>'; echo '<th scope="col"></th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; if ($handle = opendir('uploads/private/'.$user1)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".htaccess") { $icon = ShowFileIcon($file); $listitem='<tr><td width="358" align="left" valign="middle"><img src="images/icons/' .$icon. '" border="0" width="18" align="absmiddle"/> <a href="'. $_SERVER['PHP_SELF'] . '?file=uploads/private/'.$user1.'/'.$file. '" title="Download '.$file.'">'.$file.'</a></td>'; echo $listitem; if ($user1 == $origuser ){ echo '<td align="center" valign="middle"><a href="deletefile.php?userid='.$user1.'&file=private/'.$user1.'/'.$file.'&userid='.$user1.'"><img src="images/delete.png" width="12" height="12" border="0" align="absmiddle" title="Delete '.$file.'"/></a></td>'; } else { echo '<td align="center" valign="middle"></td>'; } echo '<tr/>'; } } echo '</tbody></table>'; } closedir($handle); echo '<br/><a href="uploadprivatefile.php?userid='.$user1.'"><img src="images/private_folder.png" border="0" width="24" height="24" align="absmiddle"/></a>'; echo ' <a href="uploadprivatefile.php?userid='.$user1.'">Upload file to private folder</a>'; } echo '</div></div></div>'; }else{ echo '<div align="center"><span class="style6">Pls log in!</span></div>'; } ?> and this is the Showfileicon funcion: function ShowFileIcon($file){ $ext = substr($file, strpos($file,'.'), strlen($file)-1); switch ($ext) { case ".jpg": $icon = 'jpg.png'; break; case ".jpeg": $icon = 'jpg.png'; break; case ".pdf": $icon = 'pdf.png'; break; case ".zip": $icon = 'zip.png'; break; case ".mp3": $icon = 'mp3.png'; break; case ".doc": $icon = 'doc.png'; break; case ".docx": $icon = 'doc.png'; break; case ".xls": $icon='xls.png'; break; case ".xlsx": $icon='xls.png'; break; case ".txt": $icon = 'txt.png'; break; case ".rar": $icon='rar.png'; break; case ".png": $icon='png.png'; break; default: $icon ='other.png'; } return $icon; } should look like this (of course with some CSS): Link to comment Share on other sites More sharing options...
Question
Darti
Hi,
I am looking to share out some of my files in a directory listing file management style. I want this to be presented to the web for users to access.
An example of what i am looking for is attached.
I dont want all the functions of a document management system, just maybe the ability to login and select files for download.
Does anyone know of an easy way to present the files, with the ability to download individual files or a group of files by selecting them.
The folder tree would be quite large so the presentation need to be lightweight.
The host would be linux based, and can be presented in any format, php, javascript etc...
FTP is not possible for the solution.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts