edgarmtze
edgarmtze

Reputation: 25048

How to pass url to read png files in php

If I do

$dir = './';
$files = glob( $dir . '*.png');
foreach( $files as $file) {
    echo $file;
}
?>

And store the php file in the same folder as images I would get correct png files.

If I change location of php file How can I read png files located in other folder?

If I do

$dir = 'www.site.com/content/images';
$files = glob( $dir . '*.png');
foreach( $files as $file) {
    echo $file;
}

it does not display anything, is it necessary to the php file with code to be in the same folder of images?

Upvotes: 2

Views: 218

Answers (2)

paddy
paddy

Reputation: 63471

If you are in fact trying to retrieve files on a remote server, look at this:

http://www.php.net/manual/en/features.remote-files.php

Upvotes: 1

Heavy
Heavy

Reputation: 1900

You shouldn't add "www.site.com" to path. You should use absolute path from the root of your server (beginning with "/": /content/images) or relative path from current location of php script (content/images).

Upvotes: 2

Related Questions