joomla의 각 슬라이드 쇼 이미지에 대한 링크를 추가하려고하지만 확장자가없는 사진의 파일 이름을 가져 오는 데 막혔습니다. 모든PHP에서 확장명이없는 파일 이름 얻기
<?php
$imgrootdir = "templates/".$this->template."/images/";
if ($headerType == "0" || $headerType == "2") {
echo '<img src="'.$imgrootdir.$myimage.'" alt="" />';
} elseif ($headerType == "1" || $headerType == "3") {
$picDir= $imgrootdir.$myfolder;
$picDir .="/";
if (file_exists($picDir) && is_readable($picDir)) {
$folder = opendir($picDir);
} else {
echo '<div class="message">Error! Please check the parameter settings and make sure you have entered a valid image folder path!</div>';
return;
}
$allowed_types = array("jpg","JPG","jpeg","JPEG","gif","GIF","png","PNG","bmp","BMP");
$index = array();
while ($file = readdir ($folder)) {
if(in_array(substr(strtolower($file), strrpos($file,".") + 1),$allowed_types)) {array_push($index,$file);}
}
closedir($folder);
if($display == 'random') {shuffle($index);} else {sort($index);}
foreach ($index as $file) {
$finalpath = $picDir.$file;
// output
echo '<a href="http://testcl.net46.net/index.php/''"><img src="'.$finalpath.'" alt="'.$file.'" /></a>';
}
if ($showControl) echo '<div id="slcontrol"> </div>';
}
?>
당신이 말했지만, 대신 확장자를 제외한 파일 이름, 확장자없이 인덱스를가했습니다. 도와주세요. 현재 코드는 다음과 같습니다 :'// output $ name = JFile :: stripExt ($ filename); echo ''; } if ($ showControl) echo '
'; } ?> – mwentahref = "testcl.net46.net/index.php/"..$ 이름 끝에 실제 파일 이름이있는 것으로 가정합니다. 예 : mypic.jpg. "/ index. php/"는 폴더가 아니며 파일 자체입니다 mypic.jpg가 사이트의 루트 디렉토리에 있다면 href ="testcl.net46.net/$name " – skibulk
시도해도됩니다. 모든 이미지는 http://testcl.net46.net/index와 404s 링크를 가지고 있습니다. 내 페이지에 대한 링크는 http://testcl.net46.net/index.php/link입니다. 그래서 index.php를 앞에 두었습니다. $ name .. 내가 코드를 넣어야하는 위치를 알려주시겠습니까? – mwenta