Autor Zpráva
WebMaster.Popi
Profil *
mám menší problém - chci prohledávat podsložku, ale když Dir(".") změním např na Dir("./podslozka") tak to nefunguje, vypíše mi to chyby s názvy obrázků, které jsou v podsložce např.

"Warning: stat failed for foto_01.jpg (errno=2 - No such file or directory) in c:apachehtdocsovoce-zeleninafotografie1fotografie.php on line 6"

nevíte někdo co stím? pls help!

tady je kód:

[pre]
<?php
$adresar = Dir(".");
while ($polozka=$adresar->Read())
{
$size = FileSize($polozka);
if (Is_File($polozka) AND $size>1000)
echo "<a href="../$polozka"><img src="$polozka" alt="" border="0" /></a>";
}
$adresar->Close();
?>

[/pre]
Ssob
Profil
WebMaster.Popi
$polozka to je jednom jmeno souboru (bez cesty). Ja bych to udelal tak:

<?php
$adresar = Dir(".");
while ($polozka=$adresar->Read())
{
$soubor = $adresar.$polozka;
$size = FileSize($soubor);
if (Is_File($soubor) AND $size>1000)
echo "<a href="$soubor"><img src="$soubor" alt="" border="0" /></a>";
}
$adresar->Close();
?>
WebMaster.Popi
Profil *
takhle mi to nefunguje, musím změnit

$soubor = $adresar.$polozka;  na třeba  $soubor = "fotogalerie/".$polozka; 


neboť když tam nechám proměnou adresar, odkazuje se to do Objectfoto_01.jpg a vůbec - když si nechám vypsat proměnou adresář, je pořád "Object" to nechápu... takže budu rád pokud mi to někdo objasní.

každopádně díky Ssob!
WebMaster.Popi
Profil *
tak jsem to ještě drobátko vylepšil, kdyby se někomu hodilo... kontroluje, jestli je to soubor, potom jestli jsou rozměry 640 x 480 a pak se vytvoří soubor kterej si načítá obrázek (kdyby se odkazoval jen na soubor jpg, budou kolem obrázku nehezké okraje....)

<?php

$adresar = dir("fotografie1_images/");
while ($fotka=$adresar->read()) {
$soubor = "fotografie1_images/".$fotka;
if (is_file($soubor)) {
list($width, $height) = getimagesize("$soubor");
if ($width == "640" && $height == "480") {
$fp = fopen("fotografie1_pages/$fotka.php", "w");
fwrite($fp, "<title>$title</title> ");
fwrite($fp, "<style type="text/css"><!--body{margin:0px}--></style> ");
fwrite($fp, "<img src="../$soubor" alt="" onclick="window.close()"> ");
fclose($fp);
echo "<a href="fotografie1_pages/$fotka.php" onclick="openCEwindow();" target="CE" class="one"><img src="$soubor" width="66" height="50" alt="" class="img" style="margin:0px 10px 10px 0px"></a> ";
}
}
}
$adresar->close();
?>
WebMaster.Popi
Profil *
[pre]<?php
$adresar = dir("fotografie1_images/");
while ($fotka=$adresar->read()) {
$soubor = "fotografie1_images/".$fotka;
if (is_file($soubor)) {
list($width, $height) = getimagesize("$soubor");
if ($width == "640" && $height == "480") {
$fp = fopen("fotografie1_pages/$fotka.php", "w");
fwrite($fp, "<title>$title</title> ");
fwrite($fp, "<style type="text/css"><!--body{margin:0px}--></style> ");
fwrite($fp, "<img src="../$soubor" alt="" onclick="window.close()"> ");
fclose($fp);
echo "<a href="fotografie1_pages/$fotka.php" onclick="openCEwindow();" target="CE" class="one"><img src="$soubor" width="66" height="50" alt="" class="img" style="margin:0px 10px 10px 0px"></a> ";
}
}
}
$adresar->close();
?>[/pre]
WebMaster.Popi
Profil *
<?php

$adresar = dir("fotografie1_images/");
while ($fotka=$adresar->read()) {
$soubor = "fotografie1_images/".$fotka;
if (is_file($soubor)) {
list($width, $height) = getimagesize("$soubor");
if ($width == "640" && $height == "480") {
$fp = fopen("fotografie1_pages/$fotka.php", "w");
fwrite($fp, "<title>$title</title>");
fwrite($fp, "<style type="text/css"><!--body{margin:0px}--></style>");
fwrite($fp, "<img src="../$soubor" alt="" onclick="window.close()">");
fclose($fp);
echo "<a href="fotografie1_pages/$fotka.php" onclick="openCEwindow();" target="CE" class="one"><img src="$soubor" width="66" height="50" alt="" class="img" style="margin:0px 10px 10px 0px"></a> ";
}
}
}
$adresar->close();
?>
WebMaster.Popi
Profil *
až napotřetí :-D
Ssob
Profil
WebMaster.Popi
Jo jasne. Blbe jsem se na to podival (asi uz jsem spal).
Jinak to jde take tak:


$adresar = "fotografie1_images/";
$stream = dir($adresar);

while ($fotka=$stream->read()) {

$soubor = $adresar.$fotka;
(...)


Ted tam jenom jednou vkladas jmeno podslozky, cili to je vlidnejsi na pripadne upravy..

edit: mala chybicka
Toto téma je uzamčeno. Odpověď nelze zaslat.

0