PHP:Scripts

From My Notepad
Jump to: navigation, search

Display all JPG files in the current directory

<?php

exit;

$cwd = $_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"];

echo $cwd;

$images = glob("$cwd/*.jpg");

foreach ($images as $value) {
        echo '<img src="'. basename($value) . '" /><br/>';
}

?>

Redirect to another URL

<?php
# Uncomment the following line for URL redirection
# $PHPREDIR_LOCATION = "Location: ".$_REQUEST['url'];

# Uncomment the following line for static redirection
# Change where to the URL you want to redirect to
# $PHPREDIR_LOCATION = "Location: http://where";

#print $PHPREDIR_LOCATION;
header($PHPREDIR_LOCATION);
?>