When you get blank pages, you need to check your error logs. Your last one has no closing semicolon so it will error. Or add, at the top of your scripts,
error_reporting(E_ALL);
ini_set('display_errors',1); // or true instead of 1
According to the
manual [php.net] it doesn't look like you're using glob() correctly. Also note my addition in the path. Any file system operations are NOT URL's, they are system paths.
Same is true of $filesize - unless it's wherever PHP is executing (e.g., in the same directory) you need the full file system path.
Last, what's with the funny curly quotes?
echo ‘‘.$image.’‘;
I don't even know if those are valid. Do not edit PHP code in a rich text editor like MS Word. This will hose you up every time. If you don't have anything else, use Notepad (and then get something else.)
<?php
$directory = $_SERVER['DOCUMENT_ROOT'] . "/wp-content/uploads/2012/05/";
// ALWAYS CHECK FIRST
if (is_dir($directory)) {
foreach (glob($directory.'*.pdf') as $pdf) {
echo "<p>$pdf size " . filesize("$directory/$pdf") . "</p>\n";
}
}
// THEN ERROR TRAP
else { echo "<p>Umm, $directory is not a directory.</p>"; }
?>
Trry that on for size. If you get "not a directory" try removing the trailing slash from the path:
$directory = $_SERVER['DOCUMENT_ROOT'] . "/wp-content/uploads/2012/05"; // <-- that one
The only thing I'm not sure about is filesize - is the full path stored in $pdf already? (Don't think it is.)