xls bestanden zoeken
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(is_dir($_POST['m:/map/'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['trefwoord']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(is_dir($_POST['m:/map/'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['trefwoord']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
In welke regel en hoe moet ik aangeven, dat die automatisch moet zoeken op .xls bestanden?
Stefan:
Je kan het dan beter zo doen ;)
De eer is voor jou hoor Stefan, maar je moet er wel op letten dat je een variabele altijd met het $ teken begint ;)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$ext = explode( ".xls", $bestandsnaam );
$ext = end($ext);
if(is_dir($_POST['m:/map/'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['trefwoord']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$ext = explode( ".xls", $bestandsnaam );
$ext = end($ext);
if(is_dir($_POST['m:/map/'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['trefwoord']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
Waarschijnlijk zal je $bestandsnaam nog moeten verwijzen e.d. Want hij zegt ook, undefined variable bestandsnaam.
Maar hoe moet ik het in dit stuk script toepassen :$
Stefan:
typfoutje, kan altijd voorkomen.
je moet $bestandsnaam laten verwijzen naar je form waar <input type="file" name=""> staat, en wat je bij name invult, dat wordt dan $bestandsnaam, dus bijv.
<input type="file" name="bestand">
ik zie bij jou ook geen form, dus kan het niet helemaal voor je beantwoorden.
Gewijzigd op 08/11/2005 15:07:00 door Stefan van Iwaarden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?
[code]<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$bestandsnaam = $_POST['bestand'];
$ext = explode( "xls", $bestandsnaam );
$ext = end($ext);
if(is_dir($_POST['m:/map'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['bestand']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
</table>
<form method="POST" action="<?=$_SERVER['PHP_SELF'] ?>">
<table width="500" border="0" align="center">
<tr>
<td>Zoek:</td>
<td width="420" align="left" scope="col"><span class="label">
<label for="trefwoord"></label>
</span>
<input id="trefwoord" name="bestand" type="text" size="21" value=""></div></td>
</tr>
<tr>
<td> </td>
<td width="214"><input name="m:/map/" type="hidden" value="m:/map/" /></td>
</tr>
</table>
<table width="500" align="center">
<tr>
<td></td>
</tr>
<tr>
<td></td>
<th width="420" scope="col"><div align="left"><input type="submit" name="submit" value="Zoek"></div></th>
</tr>
</table>
</form>
<?
}
?>
?>
[code]<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$bestandsnaam = $_POST['bestand'];
$ext = explode( "xls", $bestandsnaam );
$ext = end($ext);
if(is_dir($_POST['m:/map'])) {
$od = opendir($_POST['m:/map/']);
while (false !== ($file = readdir($od))) {
if(!is_dir($file)) {
if(preg_match("/".$_POST['bestand']."/i",$file)) {
echo '<a href="'.$_POST['m:/map/'].$file.'" TARGET="_blank">'.$file.'</a><br><br />';
}
}
}
closedir($od);
}
else
{
echo 'Geen geldige map opgegeven';
}
} else {
//het zoek form
?>
</table>
<form method="POST" action="<?=$_SERVER['PHP_SELF'] ?>">
<table width="500" border="0" align="center">
<tr>
<td>Zoek:</td>
<td width="420" align="left" scope="col"><span class="label">
<label for="trefwoord"></label>
</span>
<input id="trefwoord" name="bestand" type="text" size="21" value=""></div></td>
</tr>
<tr>
<td> </td>
<td width="214"><input name="m:/map/" type="hidden" value="m:/map/" /></td>
</tr>
</table>
<table width="500" align="center">
<tr>
<td></td>
</tr>
<tr>
<td></td>
<th width="420" scope="col"><div align="left"><input type="submit" name="submit" value="Zoek"></div></th>
</tr>
</table>
</form>
<?
}
?>
?>
Gewijzigd op 08/11/2005 15:37:00 door Dirk B
Is er een oplossing :$?
Schijnbaar niet.....