file-uploaden-in-verkenner

Gesponsorde koppelingen

PHP script bestanden

  1. file-uploaden-in-verkenner

« Lees de omschrijving en reacties

//-------------------------------------
//-----------index.php---------------
//-------------------------------------

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php include('top.php'); ?>
<font color="#000000">    <div style="background-color: #F2F2EE; border: 1px solid #DDDDDD; width:705px; " id="verkenner">
<a href="javascript:history.go(-1)"><img src="img/folder_back.gif" border="0"></a>
        <a href="javascript:history.go(+1)"><img src="img/folder_forward.gif" border="0"></a><a href="../index.php"><img src="img/index.png" border="0" alt="Ga naar de hoofdpagina..."></a></div>
        <div style="background-color: #F2F2EE; border-center: 1px solid #FFFFFF; border-top: 1px solid #DDDDDD; border-bottom: 1px solid #FFFFFF; width:50px; float:center; ">


<div style="background-color: #F2F2EE; border-right: 1px solid #DDDDDD; border-top: 1px solid #DDDDDD; border-bottom: 1px solid #FFFFFF; width:550px; float:center; ">&nbsp;&nbsp;<?=$totaal_bestanden?>
<?php

echo "<title>Upload een file</title>";


if (!is_dir("bestanden/")) {
    die ("dir bestaat niet");
}


if ($_FILES['userfile']) {
    $message = do_upload($upload_dir, $upload_url);
}

else {
    $message = "Upload file";
}



function
do_upload($upload_dir, $upload_url) {

if($_POST["dir"]=="bestanden") {
    $upload_dir = "bestanden/";
    }


elseif($_POST["dir"]=="mysql") {
    $upload_dir = "bestanden/";
    }


    else {
    $upload_dir = "bestanden/";
    }


    $temp_name = $_FILES['userfile']['tmp_name'];
    $file_name = $_FILES['userfile']['name'];
    $file_type = $_FILES['userfile']['type'];
    $file_size = $_FILES['userfile']['size'];
    $result    = $_FILES['userfile']['error'];
    $file_url  = $upload_url.$file_name;
    $file_path = $upload_dir.$file_name;

    //File Name Check
    if ( $file_name =="") {
        $message = "Foute file name";
        return $message;
    }

    //File Size Check
    else if ( $file_size > 500000) {
        $message = "Groter dan 500k.";
        return $message;
    }

    //File Type Check
    else if ( $file_type == "text/plain" ) {
        $message = "Sorry, geen scripts uploaden" ;
        return $message;
    }


    $result  =  move_uploaded_file($temp_name, $file_path);
    $message = ($result)?"File url <a href=$file_url>$file_url</a>" :
              "Er klopt iets niet met het bestand.";

    return $message;
}

?>

<div align="center"><form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">Upload bestand: <input type="file" id="userfile" name="userfile"><hr>
<input type="submit" name="upload" value="Upload"></div>
</form>
<hr>  
<?php include('verkenner.inc'); ?>
        </div>

        


</div>
<?php include('bottom.php'); ?>

//----------------------------------
//-------verkenner.inc-----------
//----------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<?
$pagina
= "index.php";
$map = "bestanden/";
$naam_root = "Bestanden";
$map_icoontjes = "img/";
?>

<html>
<head>
<title>Verkenner.php</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
BODY
    {
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
    margin-top:20px;
    }

#Main
    {
    width:710px;
    margin:auto;
    padding:auto;
    height:auto;
    }
    
#Map_structuur
    {
    width:300px;
    height:400px;
    padding: 0px 0px 0px 3px;
    margin: 0px 0px 0px 0px;
    border: 1px solid #EEEEEE;
    overflow:scroll;
    float:left;
    background-color:#FFFFFF;
    }
            
    #Map_structuur a
        {
        color: #000000;
        text-decoration:none;
        }
                
            
    #Map_structuur a:hover
        {
        color: #000000;
        text-decoration:underline;
        }
                
#Map_self
    {
    width:400px;
    height:400px;
    padding: 0px 0px 0px 0px;
    margin: 0px 0px 0px 0px;
    border: 1px solid #EEEEEE;
    overflow:scroll;
    float:left;
    background-color:#FFFFFF;
    }
            
    #Map_self a
        {
        color: #000000;
        text-decoration:none;
        }
                
            
    #Map_self a:hover
        {
        color: #000000;
        text-decoration:none;
        }
</style>

<script language="javascript" type="text/javascript">
function link(url)
    {
    window.location.href= url;
    }
</script>

</head>

<body link="#000000" vlink="#000000" alink="#000000" hlink="#000000">
<center>
<div id="Main">

<?

function file_size($size, $stap)
            {

            $naam_eenheid = array('1' => 'B', '2' => 'kB', '3' => 'mB', '4' => 'gB');
            if($size >= 1024)
                {

                $size = $size / 1024;
                $stap = $stap + 1;
                file_size($size, $stap);
                }

            
            else
                {
                echo(round($size).$naam_eenheid[$stap]);
                }
            }

$parts = explode("/", $_GET["folder"]);
$aantal = count($parts);
$i = 0;
while($i < ($aantal-2))
    {

    $vorige .= $parts[$i]."/";
    $i++;
    }

?>


    <div style="background-color: #F2F2EE; border: 1px solid #DDDDDD; width:705px; " id="verkenner">
    
        
        <a href="<?=$pagina?>?folder=<?=$vorige?>#verkenner"><img src="<?=$map_icoontjes?>folder_omhoog.gif" border="0"></a>
        
    </div>
    
    <div style=" padding: 3px 0px 3px 0px; background-color: #F2F2EE; border-left: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD; width:705px; ">
    
        &nbsp;Adres: <input type="text" value="<?=$naam_root?>:\<?
        $locatie
= str_replace("/","\\",$_GET["folder"]);
        echo($locatie); ?>
" size="106">
    
    </div>
        
    <div id="Map_structuur">
        
        <div style="background-color:#CCCCCC; padding: 5px 0px 5px 0px; margin: 0px 0px 10px 0px; width:300px; ">
        
            Mappen
        
        </div>
        
        <table cellpadding="0" cellspacing="0" border="0" width="280">
        
            <tr>
        
                <td><a href="<?=$pagina?>?folder=#verkenner"><img src="<?=$map_icoontjes?>disk.gif" border="0" height="18" style="vertical-align: middle; float:left; ">&nbsp;<?=$naam_root?></a></td>
                
            </tr>
        <?
        function verkennen($pagina, $map, $folder, $laag, $parts, $last, $map_icoontjes)
            {

            $parts = explode("/", $_GET["folder"]);
            $aantal = count($parts);
            $dir = $map.$folder;
            
            if ($dh = opendir($dir))
                {

                while (($file = readdir($dh)) !== false)
                    {

                    if($file != "." && $file != "..")
                        {

                        if(filetype($dir . $file) == "dir")
                            {

                            $wijdte = ($laag * 20) + 160;
                            ?>

                            
                <tr>
                
                    <td width="<?=$wijdte?>"><?
                            $not_empty
= "";
                            
                            if ($dh2 = opendir($dir.$file))
                                {

                                while (($file2 = readdir($dh2)) !== false)
                                    {

                                    if($file2 != "." && $file2 != "..")
                                        {

                                        if(filetype($dir.$file."/".$file2) == "dir")
                                            {

                                            $not_empty = $file2;
                                            }
                                        }
                                    }

                                closedir($dh2);
                                }

                            if(!$not_empty)
                                {

                                $i = -1;
                                while($i < $laag)
                                    {

                                    ?>
<img src="<?=$map_icoontjes?>map_not_up<?
                                    if($file == $last)
                                        {

                                         if(($laag-1) == $i)
                                            {

                                            echo("_end");
                                            }
                                        }
?>
.gif" style="vertical-align: middle; float:left; "><?
                                    $i
++;
                                    }
                                }

                            if($not_empty)
                                {

                                $i = 0;
                                while($i < $laag)
                                    {

                                    ?>
<img src="<?=$map_icoontjes?>map_not_up.gif" style="vertical-align: middle; float:left; "><?
                                    $i
++;
                                    }

                                ?>
<a href="<?=$pagina?>?folder=<?=$folder.$file?>/#verkenner"><img src="<?=$map_icoontjes?>map_up<?
                                    if($file == $last)
                                        {

                                        
                                            echo("_end");
                                            
                                        }
?>
.gif" style="vertical-align: middle; float:left; " border="0"></a><?
                                }
                            ?>
<a href="<?=$pagina?>?folder=<?=$folder.$file?>/#verkenner"><img src="<?=$map_icoontjes?>folder2.gif" border="0" height="18" style="vertical-align: middle; float:left;"><? if($parts[($aantal-2)] == $file) { ?><div style="background-color:#AAAAAA; float:left; margin: 1px 0px 1px 0px; "><? } ?>&nbsp;<?=$file?><? if($parts[($aantal-2)] == $file) { ?></div><? } ?></a></td>
                            
                </tr>
                            
                            <?
                            if($parts[$laag] == $file)
                                {

                                $laag_temp = $laag + 1;
                                verkennen($pagina, $map, $folder.$file."/", $laag_temp, $parts, $not_empty, $map_icoontjes);
                                }
                            
                            }
                        }
                    }

                closedir($dh);
                }
            }

            
        $laag = 0;
        $parts = explode("/", "/".$_GET["folder"]);    
        if ($dh2 = opendir($map))
            {

            while (($file2 = readdir($dh2)) !== false)
                {

                if($file2 != "." && $file2 != "..")
                    {

                    if(filetype($map.$file2) == "dir")
                        {

                        $not_empty = $file2;
                        }
                    }
                }

                closedir($dh2);
            }

            
        verkennen($pagina, $map, '', $laag, $parts, $not_empty, $map_icoontjes);
        ?>

        
        </table>
        
    </div>
    
    <div id="Map_self">
        
        <table cellpadding="0" cellspacing="0" border="0" width="490">
        
            <tr>
            
                <td style="background-color:#DDDDDD; border-bottom:1px solid #BBBBBB; border-right:1px solid #BBBBBB;" width="200">Naam</td>
                <td style="background-color:#DDDDDD; border-bottom:1px solid #BBBBBB; border-right:1px solid #BBBBBB;" width="140">Type</td>
                <td style="background-color:#DDDDDD; border-bottom:1px solid #BBBBBB; border-right:1px solid #BBBBBB;" width="50">Grootte</td>
                <td style="background-color:#DDDDDD; border-bottom:1px solid #BBBBBB; border-right:1px solid #BBBBBB;" width="100">Laatst gewijzigd</td>
            
            </tr>
        <?
        $dir
= $map.$_GET["folder"];
        
        if ($dh = opendir($dir))
            {

            while (($file = readdir($dh)) !== false)
                {

                if($file != "." && $file != "..")
                    {

                    if(filetype($dir . $file) == "dir")
                        {

                        ?>

                        
            <tr onMouseOver="style.backgroundColor = '#EFEFEF';" onMouseOut="style.backgroundColor = '#FFFFFF';">
            
                <td style="font-size:11px; "><a href="#verkenner" onDblClick="javascript:link('<?=$pagina?>?folder=<?=$_GET["folder"]?><?=$file?>/#verkenner');"><img src="<?=$map_icoontjes?>folder2.gif" border="0" height="18" width="18" style="vertical-align: middle;"> <?=$file?></a></td>
                <td style="font-size:11px; ">Bestandsmap</div></td>
                <td style="font-size:11px; ">&nbsp;</td>
                <td style="font-size:11px; "><? echo date("d-m-Y H:i", filectime($dir.$file)); ?></td>
            
            </tr>
                        <?
                        }
                    }
                }

            closedir($dh);
            }

            
        if ($dh = opendir($dir))
            {

            while (($file = readdir($dh)) !== false)
                {

                if($file != '.'){ if($file != '..')
                    {

                    if(filetype($dir . $file) == "file")
                        {

                        $parts = explode(".", $file);
                        $aantal_punten = count($parts) - 1;
                        $extensie = $parts[$aantal_punten];
                        
                        
                        if($extensie == "pdf")
                            {

                            $icon_file = "pdf";
                            $name_type = "PDF bestand";
                            }

                        
                        $images = array('jpg', 'JPG', 'jpeg', 'JPEG');
                        for ($i = 0; $i < count($images); $i++)
                            {

                            if ($extensie == $images[$i])
                                {

                                $name_type = "JPG-afbeelding";
                                $icon_file = "img_jpg";
                                }
                            }

                            
                        $images = array('gif', 'GIF');
                        for ($i = 0; $i < count($images); $i++)
                            {

                            if ($extensie == $images[$i])
                                {

                                $name_type = "GIF-afbeelding";
                                $icon_file = "img_gif";
                                }
                            }

                            
                        $images = array('png', 'PNG');
                        for ($i = 0; $i < count($images); $i++)
                            {

                            if ($extensie == $images[$i])
                                {

                                $name_type = "PNG-afbeelding";
                                $icon_file = "img_png";
                                }
                            }

                            
                        $images = array('bmp', 'BMP');
                        for ($i = 0; $i < count($images); $i++)
                            {

                            if ($extensie == $images[$i])
                                {

                                $name_type = "Bitmapafbeelding";
                                $icon_file = "img_bmp";
                                }
                            }

                        
                        $docs = array('doc', 'docx', 'DOC', 'DOCX');
                        for ($i = 0; $i < count($docs); $i++)
                            {

                            if ($extensie == $docs[$i])
                                {

                                $name_type = "Microsoft Word-document";
                                $icon_file = "img_doc";
                                }
                            }

                        
                        $docs = array('XLT', 'xlt', 'xml', 'XML', 'xls', 'XLS', 'xlw', 'XLW');
                        for ($i = 0; $i < count($docs); $i++)
                            {

                            if ($extensie == $docs[$i])
                                {

                                $name_type = "Microsoft Exel-document";
                                $icon_file = "img_xlt";
                                }
                            }

                        
                        $docs = array('txt', 'TXT', 'DOC', 'DOCX');
                        for ($i = 0; $i < count($docs); $i++)
                            {

                            if ($extensie == $docs[$i])
                                {

                                $name_type = "Tekstdocument";
                                $icon_file = "img_txt";
                                }
                            }

                        
                        $docs = array('htm', 'html', 'HTM', 'HTML', 'xml', 'XML', 'css', 'CSS', 'php', 'PHP', 'php3', 'PHP3', 'php4', 'PHP4', 'php5', 'PHP5');
                        for ($i = 0; $i < count($docs); $i++)
                            {

                            if ($extensie == $docs[$i])
                                {

                                $name_type = "Webdocument";
                                $icon_file = "img_html";
                                }
                            }

                            
                        if((!$name_type) && (!$icon_file))
                            {

                            $name_type = $extensie."-bestand";
                            $icon_file = "img_else";
                            }

                        ?>

                        
            <tr onMouseOver="style.backgroundColor = '#EFEFEF';" onMouseOut="style.backgroundColor = '#FFFFFF';">
            
                <td style="font-size:11px; "><a href="#verkenner" onDblClick="window.open('<?=$dir.$file?>', 'Voorbeeld','status,width=400,height=400,location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes'); return false"><img height="18" width="18" src="<?=$map_icoontjes?><?=$icon_file?>.gif" border="0" style="vertical-align: middle;"> <?=substr($file, 0, 32)?></a></td>
    
      
                <td style="font-size:11px; "><?=$name_type?></div></td>
                <td style="font-size:11px; "><?
                $size
= filesize($dir.$file);
                $totaal_size += $size;
                file_size($size,"1");
                $totaal_bestanden += 1;
                ?>
</td>
                <td style="font-size:11px; "><? echo date("d-m-Y H:i", filectime($dir.$file)); ?></td>
            
            </tr>
                            
                        <?
                        }
                        $icon_file = "";
                        $name_type = "";
                    } }
                }
            }

        ?>

        
        </table>
        
        </div>
        
        <div style="background-color: #F2F2EE; border-right: 1px solid #DDDDDD; border-top: 1px solid #DDDDDD; border-bottom: 1px solid #FFFFFF; width:550px; float:left; ">&nbsp;&nbsp;<?=$totaal_bestanden?> Objecten </div>
        <div style="background-color: #F2F2EE; border-left: 1px solid #FFFFFF; border-top: 1px solid #DDDDDD; border-bottom: 1px solid #FFFFFF; width:50px; float:left; "><?=file_size($totaal_size, "1")?></div>
        <div style="background-color: #F2F2EE; border-left: 1px solid #FFFFFF; border-top: 1px solid #DDDDDD; border-bottom: 1px solid #FFFFFF; width:104px; float:left; ">&nbsp;</div>
        
    </div>

</div>
</body>
</html>

//-------------------------
//-------top.php---------
//-------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<html>
<head>
<title>Upload een file</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="JavaScript" type="text/javascript">
<!--
function confirmLink(link, text) {
 if(typeof(window.opera) != 'undefined') {
  return true;
 }
 var is_confirmed = confirm(text);
 if (is_confirmed) {
  location.href = link;
 }
 return is_confirmed;
}

function addtext(veld,text) {
 text = ''+text+' ';
 if(document.form.elements[veld].createTextRange) {
  document.form.elements[veld].focus();
  document.selection.createRange().duplicate().text = text;
 }else{
  document.form.elements[veld].focus();
  document.form.elements[veld].value += text;
 }
}

//-->
</script>
</head>
</body>
</html>

//-------------------------
//------bottom.php------
//-------------------------
//Deze pagina slaat nu nergens op, maar als je copyright wilt gebruiken...
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
</body>
</html>

De plaatjes zijn te downloaden op http://www.vleckanie.nl/phphulp/verkenner/plaatjes.zip.
Maak ook de map bestanden aan.

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.