Har två skript, det ena är ett upload skript som endast tillåter .mp3 filer, max 10mb stor och lite andra funktioner. Sen har jag ett annat skript som laddar in innehåller från en mapp (mappen med .mp3 filer) och skickar ut det i en tabell på en sida där alla filer är länkade så att säga, plus en "Ta bort länk", det är just denna Ta bort länk jag har problem med...hur gör jag för att få bort tagningen av den specifika filen att fungera..? samt så undrar jag hur jag gör för att endast tillåta uppladning OM "Ja" är ikryssad...Vill gärna också att filstorleken ska synas i mb... så här ser allt ut
Uppladdnings skriptet
<?php
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Ladda upp en fil</title>
<link rel=StyleSheet href="../../setts/style.css" TYPE="text/css">
</head>
<body class="index2">
<form name="form1" method="post" action="">
<textarea name="textarea">##Upphovsrätt## Vid uppladdning av musik med denna tjänst blablablablablablbl
</textarea><br>
Har ni läst och förstått reglerna för uppladdning av musik?<br>
Ja<input type="checkbox" name="checkbox" value="checkbox"><br><br>
</form>
<style>
<!--
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #000000;
}
.style1 {color: #FF0000}
-->
</style>
<strong>Max 10MB!</strong><br>
<strong>Endast .mp3 filer!</strong><br><br>
<?php
if (isset($_FILES['uplfile'])) {
// Mappen där filerna ska hamna
$upload_dir = 'Musik/';
// De tillåtna filtyperna, separerade med komman, utan mellanrum
$filetypes = 'mp3';
// Den största tillåtna storleken
$maxsize = (1024*10000);
// Kontrollera att det angavs en fil
if(empty($_FILES['uplfile']['name']))
die('Ingen fil har valts <br><br>');
// Kontrollera storleken
if($_FILES['uplfile']['size'] > $maxsize)
die('Filen du valde är för stor. Maxstorleken är '.(string)($maxsize/1024).' KB.');
// Kontrollera filtypen
$types = explode(',', $filetypes);
$file = explode('.', $_FILES['uplfile']['name']);
$extension = $file[sizeof($file)-1];
if(!in_array(strtolower($extension), $types))
die('Du har en felaktig filtyp. Endast .mp3 är tillåtet!<br><br>');
Visa innehållet i mappen
<html>
<head>
<link rel=StyleSheet href="../../setts/style.css" TYPE="text/css">
</head>
<style type="text/css">
<!--
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #000000;
}
.style1 {color: #FF0000}
-->
</style>
</head>
<body class="index2">
<p><strong>Min Musik:</strong><br>
<br>
<?php
$protected = array('lista.php');
$dirpath = 'Musik';
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
if (!is_dir("$dirpath/$file")) {
if (!in_array($file,$protected)) { // Kontroll
echo "
<table width='360' border='0'>
<tr>
<td width='280' class='bg1'>
<a href='$dirpath/$file'>
$file
<td width '79' class='bg1'>
<a href ='refresh.php'>
<strong> Ta Bort!</strong>
</a>
</td>
</tr>
</table>
";}}}
closedir($dh);
?>
<p>
<p>
<table width="384" border="0">
<tr>
<td width="295"> </td>
<td width="79"> </td>
</tr>
</table>
<p>
</body>
</html>
Bort tagning
<html>
<meta http-equiv="refresh" content="5;URL=minmusik.php">
</html>
<?php
require("minmusik.php");
?>
Raderar Fil.....<br><br>
<?php
unlink ('$dirpath/$file');
?>
