/    Sign up×
Community /Pin to ProfileBookmark

$_SERVER[‘DOCUMENT_ROOT’] Trip up

This works for all my linked paths, aka fetch this document from
XMLHTTPRequest from server root + Whatever trailing URL, it has
unfortunately been tripping up all my image requests for the last
week or something. It’s blatantly obvious, I’m just not seeing it.

As long as I’m on this scriptlet I might as well ask too, with my
desired extension, how would I place a -m before it to only search
images that would be something like

-m.jpg||gif||png? $fileChunks = explode(“-m”,”.”, $file);

Anyway, code here, and screw you godaddy.

[code]
$hds=”images/products/sound/”; //ignore this
$src=”images/products/sound/spkr/”;
$url=”layers/sound/pcons/”; //ignore this
$noimg=”images/”; //ignore this

$desired_extension = ‘png’||’jpg’||’gif’;
$dirname = ($_SERVER[‘DOCUMENT_ROOT’] . ‘/’ . $src);
$dir = opendir($dirname);

echo ‘<div style=”visibility:hidden;”>’;

while(false != ($file = readdir($dir)))
{
if(($file != “.”) and ($file != “..”))
{
$fileChunks = explode(“.”, $file);
if($fileChunks[1] == $desired_extension)
{
echo ‘<img src=”‘.$dirname.”.$file.'” />’;
}
}
}
closedir($dir);
echo ‘</div>’;
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 16.2009 — $_SERVER['DOCUMENT_ROOT'] gives a local file system path on the server, not a HTTP URI path. You can just use a slash in the IMG tag's SRC attribute to represent the current web domain's document root:
[code=php]
echo '<img src="/'.$src.$file.'" />';
[/code]
Copy linkTweet thisAlerts:
@ehimeauthorMar 16.2009 — $_SERVER['DOCUMENT_ROOT'] gives a local file system path on the server, not a HTTP URI path. You can just use a slash in the IMG tag's SRC attribute to represent the current web domain's document root:
[code=php]
echo '<img src="/'.$src.$file.'" />';
[/code]
[/QUOTE]


Actually ended up figuring that out on my own by accident. Second question is still open though, anyway to use -m as a defining variable in my extension?

Or atleast order things (which will be harder I'm sure) on how they load, AKA load 20x20 then 50x50 then 170x170 then 540x540? This is what worked for

me in loading images btw, codes crappy but whatever.

[code=php]

$desired_extension = 'png'||'jpg'||'gif';
$dirname = ($_SERVER['DOCUMENT_ROOT'] . '/' . $src);
$dir = opendir($dirname);

echo '<div id="preload">';

while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{
$fileChunks = explode(".", $file);
if($fileChunks[1] == $desired_extension)
{
echo '<img src="'.$src.''.$file.'" />';
}
}
}
closedir($dir);
echo '</div>';

[/code]


...edit

Swapped my echo line to the one above just for [b]safety[/b] reasons
Copy linkTweet thisAlerts:
@ehimeauthorMar 17.2009 — Up, still need to find out how to prepend my $desired_extension

with -ico, -m, -s, then no dash. The -s and no dashed tags (lets

call those the large images, even though they have no dash) are

on a secondary page, -ico and -m 's need to be cycled through

first. The others later, or not at all. *-m.jpg crashes my $desired.

[b]Any ideas?[/b]
×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...