hi ,
I create a ftp programme . I want to validate some parameter like creation date , modified date, file size etc.
Is this for files you already have in a folder, or for files as you import them?
file that import .
I’m not too sure this will help, but this is a file that’s been put together to gather file data from a folder. You may be able to adapt parts of it to do what you need.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Listings Page</title>
<link rel="stylesheet" href="css/basic.css" type="text/css" />
<?PHP
// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
// Ensures 0 byte file sizes are shown with 2 decimal places.
"size" => number_format(0,2),
"lastmod" => filemtime("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"type" => mime_content_type("$dir$entry"),
// Converts file size to kb from bytes, rounds to 2 decimal places, and formats to ensure both places are shown
"size" => number_format(round((filesize("$dir$entry") / 1024),2),2),
"lastmod" => filemtime("$dir$entry")
);
}
}
$d->close();
return $retval;
}
?>
</head>
<body>
<div id="main">
<h1>Display Folders/Files in the Root of /var/www/html/</h1>
<table cellspacing="0">
<thead>
<tr><th>Name</th><th>Type</th><th>Size (kb)</th><th>Last Modified</th></tr>
</thead>
<tbody>
<?PHP
$dirlist = getFileList(".");
$dirlist = getFileList("./");
foreach($dirlist as $file) {
echo "<tr>\n";
echo "<td><a href=\"{$file['name']}\">{$file['name']}</a></td>\n";
echo "<td>{$file['type']}</td>\n";
echo "<td class=\"alignright\">{$file['size']}kb</td>\n";
echo "<td>",date('r', $file['lastmod']),"</td>\n";
echo "</tr>\n";
}
?>
</tbody>
</table>
<!-- Footer -->
<footer>
<small>© Chris's JavaScript</small> - <a href="index.html" title="Links to all the pages on this website">Home</a>
</footer>
</div>
</body>
</html>
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.