PDA

Volledige versie bekijken : bestanden weergeven op server


beele
%Europe/Berlin %501 %2007, 13:02
Hallo allemaal.

Is het mogelijk om de bestanden die in een bepaalde map staan te doorbladeren en te downloaden vanuit flash. Hiermee bedoel ik dat je op de naam van een bestand kan klikken en dan kan je het bestand downloaden.

Is dit mogelijk, en zo ja, hoe doe ik dit, zijn er goeie tuts voor te vinden.


Alvast bedankt.

Gerrit55
%Europe/Berlin %511 %2007, 13:16
Hiervoor heb je een serversided taal nodig, zoals php of asp.

Topic hier naartoe verplaatst.

Zaxs
%Europe/Berlin %750 %2007, 19:01
Ik heb wel een php script voor je dat dit doet maar ik heb geen flauw idee hoe je dit in flash integreerd, daar is de rest op dit forum erg goed in volgens mij.


<?php

## File Browser v1.3
## by Marc Hollander (marc.hollander@home.nl)
## Copryright StreetAngel.nl

$dirs = array();
$files = array();

$icons['audio'] = array('mp3', 'mpg', 'mpeg', 'avi', 'wma', 'wmv', 'wav');
$icons['excel'] = array('xls');
$icons['exe'] = array('exe');
$icons['txt'] = array('txt');
$icons['fla'] = array('fla', 'flv', 'swf');
$icons['html'] = array('htm', 'html', 'xhtml', 'tpl');
$icons['php'] = array('php');
$icons['pic'] = array('jpg', 'jpeg', 'gif', 'bmp', 'png');
$icons['ppt'] = array('ppt');
$icons['script'] = array('js');
$icons['txt'] = array('txt');
$icons['word'] = array('doc', 'rtf');
$icons['zip'] = array('zip', 'rar', 'ace');

if(!isset($_GET['dir']))
$_GET['dir'] = './';
else {

$_GET['dir'] = str_replace('..', '.', $_GET['dir']);

if(is_dir($_GET['dir']))
chdir($_GET['dir']);
else
$_GET['dir'] = '.onbekend';

}

$dir = opendir("./");

while (false !== ($entry = readdir($dir))) {

if(is_dir($entry))
$dirs[] = $entry;
else
$files[] = $entry;

}

closedir($dir);

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
echo '<title>Map: ' . substr($_GET['dir'], 1) . '</title>';
echo '<style type="text/css">';
echo 'body { line-height: 20px; color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }';
echo 'a { color: #000000; text-decoration: none; }';
echo 'a:hover { color: #000000; text-decoration: underline; }';
echo '</style>';

echo '</head>';
echo '<body>';

echo '<h1>Map: ' . substr($_GET['dir'], 1) . '</h1>';
echo '<div style="width: 30px; float: left;">&nbsp;</div>';
echo '<div style="width: 300px; float: left;"><b>Bestand:</b></div>';
echo '<div style="width: 50px; float: left;"><b>Type:</b></div>';
echo '<div style="width: 125px; float: left;"><b>Grootte:</b></div>';
echo '<div style="width: 200px; float: left;"><b>Laatst bewerkt op:</b></div><br />';
echo '<hr />';

if($_GET['dir'] != './') {
echo '<div style="width: 30px; float: left;"><img src="browser_img/folderup.png" width="16" height="16" alt="map" /></div>';
echo '<div style="width: 300px; float: left;"><a href="javascript:history.go(-1);">Map terug</a></div><br />';
}

if($_GET['dir'] == ".onbekend") {

echo '<div style="width: 30px; float: left;">&nbsp;</div>';
echo '<div style="float: left;">De opgevraagde map bestaat niet of deze mag je niet bekijken !</div><br />';

}
else {

sort(array_change_key_case($dirs, CASE_LOWER));
foreach($dirs as $dir) {

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

echo '<div style="width: 300px; float: left;"><a href="' . $_SERVER['PHP_SELF'] . '?dir=' . urlencode($_GET['dir'] . $dir) . '/">' .$dir . '</a></div>';
echo '<div style="width: 50px; float: left;">map</div>';
echo '<div style="width: 125px; float: left;">' . count(glob($dir . '/*')) . ' bestanden</div>';
echo '<div style="width: 200px; float: left;">' . date("d M Y H:i", filemtime($dir)) . '</div><br />';

}
}

sort(array_change_key_case($files, CASE_LOWER));
foreach($files as $file) {

$type = explode(".", $file);

$icon = 'file';
foreach($icons as $iconName => $iconRange) {
if(in_array(strtolower($type[(sizeof($type) - 1)]), $iconRange))
$icon = $iconName;
}

echo '<div style="width: 300px; float: left;"><a href="' . $_GET['dir'] . $file . '">' . $file . '</a></div>';
echo '<div style="width: 50px; float: left;">' . strtolower($type[(sizeof($type) - 1)]) . '</div>';
echo '<div style="width: 125px; float: left;">' . ceil((filesize($file) / 1024)) . ' kb</div>';
echo '<div style="width: 200px; float: left;">' . date("d M Y H:i", filemtime($file)) . '</div><br />';

}

}

echo '<hr />';
echo '<div style="float: right">Copyrighted StreetAngel.nl, all rights reserved.</div>';
echo '</body>';
echo '</html>';

?>

Zoals vermeld: ik heb dit zeer handige stukje code niet zelf geschreven, credits gaan naar:
## File Browser v1.3
## by Marc Hollander (marc.hollander@home.nl)
## Copryright StreetAngel.nl

Er horen allemaal icoontjes bij, vertel me maar als je die ook wil.

BernardV
%Europe/Berlin %767 %2007, 19:25
Dit script zou ik niet zo gebruiken.
Er is geprobeerd een beveiliging in te bouwen door .. te vervangen door . zodat je niet een folder terug kunt, maar als je dus .... opgeeft wordt dat .. en ga je alsnog een folder terug.

Verder werkt het prima hoor, maar een beetje extra beveiliging is wel nodig.

beele
%Europe/Berlin %658 %2007, 16:47
Ik zal het eens bekijken, alvast bedankt voor de hulp