Upload af flere filer
Jeg har en kode, som skal uploade to filer og ændre nogle ting i MySQL databasen... Det virker fint, men den uploader ikke filerne...<? if (empty($_GET[gem])) { ?>
<font size="+1">Næste kamp</font><br><br>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0A2160" width="308" id="AutoNumber2" height="8">
<tr>
<td width="100%" bgcolor="#0A2160" height="11">
<font face="Verdana" color="#FFFFFF" size="2"><b>Næste kamp</b></font></td>
</tr>
<tr>
<td width="100%" height="7">
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3">
<tr>
<td width="100%" background="http://www.fcknet.dk/billeder/nextmatch_bg.jpg">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
<tr>
<td width="50%"><div align="center"><img src="spacer" height="5"><br><img src="http://www.fcknet.dk/billeder/nextlogo_home.gif"><br><img src="spacer" height="5"></div></td>
<td width="50%"><div align="center"><img src="spacer" height="5"><br><img src="http://www.fcknet.dk/billeder/nextlogo_away.gif"><br><img src="spacer" height="5"></div></td>
</tr>
<tr>
<td width="100%" colspan="2"><center><font face="Verdana" style="font-size: 15px" color="#092161"><b><i><? config("1","") ?> - <? config("2","") ?></i></b></font>
<br><img src="spacer" height="4"><br><font face="Tahoma" style="font-size: 9px" color="#092161"><? config("3","uppercase") ?><br>
<b><? config("4","uppercase") ?></b> - <? config("5","uppercase") ?></center></td>
</tr>
</table></table></table>
<form enctype="multipart/form-data" action="nextmatch.php?gem=true" method="post">
<table>
<tr><td colspan="2"><div align="center"><font size="+1">Rediger box</font><br></div></td></tr>
<tr><td>Billede til hjemmehold:</td>
<td><input type="file" name="upfile[]"></td>
</tr>
<tr><td>Billede til udehold:</td>
<td><input type="file" name="upfile[]"></td>
</tr>
<tr><td>Hjemmehold næste kamp:</td>
<td><input type="text" name="hjemmehold" size="35"></td>
</tr>
<tr><td>Udehold næste kamp:</td>
<td><input type="text" name="udehold" size="35"></td>
</tr>
<tr><td>Turnering:</td>
<td><input type="text" name="turnering" size="35"></td>
</tr>
<tr>
<td>Dato, tid:</td>
<td><input type="text" name="dato" size="35"></td>
</tr>
<tr>
<td>Stadion, by:</td>
<td><input type="text" name="stadion" size="35"></td>
</tr>
<tr>
<td><input type="submit" value=" Gem "></td>
<td></td></tr>
</table>
</form>
<? } else {
if (empty($_POST[hjemmehold]) || empty($_POST[udehold]) || empty($_POST[turnering]) || empty($_POST[dato]) || empty($_POST[stadion])) {
echo "Du mangler at udfylde et eller flere felter!";
} else {
function configchange($id, $til) {
include("database.php");
mysql_connect($server, $db_user, $db_pass) or die ("Database fejl");
mysql_select_db($database);
mysql_query("update config set tekst = '$til' where id = '$id'");
}
configchange("1", $_POST[hjemmehold]);
configchange("2", $_POST[udehold]);
configchange("3", $_POST[turnering]);
configchange("4", $_POST[dato]);
configchange("5", $_POST[stadion]);
$dist = "../billeder";
for($i = 0; $i < count($_FILES['upfile']['name']); $i++) {
if (isset($_FILES['upfile']['name'][$i]) && $_FILES['upfile']['name'][$i] !="") {
if(is_uploaded_file($_FILES['upfile']['tmp_name'][$i])) {
if ($i == 1) {
move_uploaded_file($_FILES['upfile']['tmp_name'][$i], $dist . "hjemmehold.gif");
} else {
move_uploaded_file($_FILES['upfile']['tmp_name'][$i], $dist . "udehold.gif");
}
} else {
echo"Der opstod en fejl under upload!<br>";
}
}
}
}
}
?>