---
title: "Opendir"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/81004-opendir"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "maxj"
published: "2003-07-01T14:47:49.000Z"
updated: "2003-07-01T21:03:11.000Z"
replies: 1
views: 283
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/81004-opendir"
---

# Opendir

## #1 — maxj, 2003-07-01T14:47Z

\<?php
		
		
		function Cache() 
{ 
header("Pragma: no-cache"); 
header("Cache-control: no-cache"); 
}
$filedir2 = "arbet/graf";
$filedir = "arbet/graf/sma";
$dh = opendir($filedir);
while(gettype($file = readdir($dh)) != boolean)
{
if (is_dir("$filedir/$file")) {
} else {
$size = getimagesize("$filedir2/$file");
$info = pathinfo("$file");
$ext = $info\["extension"\];
echo "\<tr onMouseOver=\\"this.style.backgroundColor='#eeeeee';\\" onMouseOut=\\"this.style.backgroundColor='';\\"\>";
echo "\<a href=\\"$filedir2/$file\\" onclick=\\"javascript:return iPop(this.href,$size\[0\],$size\[1\],'$file')\\"\>\<img src=\\"$filedir/$file\\"\>\</a\>";

} 
}
closedir($dh);
?\>

hur ska jag få den här koden att bara visa bilder?

Permalänk: https://www.webforum.nu/p/81004

## #2 — Matte, 2003-07-01T21:03Z

Testa det här:

```
if ($size = @getimagesize("$filedir2/$file")) { 
    $info = pathinfo("$file"); 
    $ext = $info["extension"]; 
    echo "<tr onMouseOver=\"this.style.backgroundColor='#eeeeee';\" onMouseOut=\"this.style.backgroundColor='';\">"; 
    echo "<a href=\"$filedir2/$file\" onclick=\"java script:return iPop(this.href,$size[0],$size[1],'$file')\"><img src=\"$filedir/$file\"></a>"; 
}
```

Permalänk: https://www.webforum.nu/p/1099565

---

Tråden på webben: https://www.webforum.nu/amne/php/81004-opendir
