Php > Directories
Open directory and File download
Open directory and File download These are the files in the directory:\n"; $mydir .= "
\n"; $mydir .= "
\n"; $mydir .= "
... \n"; while (false !== ($file = readdir($handle))) { $files[] = $file; } sort($files); foreach ($files as $val) { if ($val != "." && $val != "..") { $mydir .= "
"; $mydir .= (strlen($val) > 30) ? substr($val, 0, 30)."...\n" : $val."\n"; $teller++; } } $mydir .= "
"; $mydir .= "
"; $mydir .= "
\n"; closedir($handle); } if ($teller == 0) { echo "No files!"; } else { echo $mydir; } } if (isset($download)) { $fullPath = $folder.$_POST['file_in_folder']; if ($fd = fopen ($fullPath, "r")) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "png": header("Content-type: image/png"); header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); break; case "zip": header("Content-type: application/zip"); header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); break; default; header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); } header("Content-length: $fsize"); header("Cache-control: private"); while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd); exit; } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage