<?php /* Start Verwerking */ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $ext = $_FILES['type']; $file_name = md5(rand(0, 1000).'-'.time()).$ext.".jpg"; $target_path = "../photo/".$_POST['album']."/".$file_name; $ar = array(); $ar[0] = 'image/jpeg'; $title = mysql_real_escape_string($_POST['title']); $description = mysql_real_escape_string($_POST['description']); $album = mysql_real_escape_string($_POST['album']); if(isset($_POST['send'])){ $fouten = array(); if (empty($_POST['title'])){ $fouten[] = "Geen naam ingevuld!"; } if(empty($_POST['description'])){ $fouten[] = "Geen beschrijving ingevuld!"; } if(empty($_POST['album'])){ $fouten[] = "Geen album opgegeven!"; } if(empty($_FILES['file']['name'])){ $fouten[] = "Geen foto geselecteerd!"; } if(!in_array($_FILES['file']['type'],$ar)){ $fouten[] = "Verkeerd bestandstype!"; } $counter = count($fouten); if($counter > 0){ echo " <font color='#FF0000'> <ol> <font color='#000000'>De volgende velden zijn niet correct ingevuld:</font> <li>".join("</li> <li>", $fouten)."</li> </ol> </font>"; } } if($counter == 0){ if(in_array($_FILES['file']['type'],$ar)){ $sql = "INSERT INTO photo_photo(id, title, description, album, file) VALUES ('','".$title."', '".$description."', '".$album."', '".$file_name."')"; mysql_query($sql); move_uploaded_file($_FILES['file']['tmp_name'], $target_path); echo "<br>Foto is succesvol geüpload en in het album geplaatst.<br>"; } } } /* Einde Verwerking */ $photo = "SELECT * FROM photo_photo"; $photo = mysql_query($photo); $album = "SELECT * FROM photo_album ORDER BY id"; $album = mysql_query($album); ?> <form name="photo_add" method="post" action="<?php $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data"> <table> <tr> <td>Naam</td> <td><input type="text" name="title" size="45" /></td> </tr> <tr> <td>Beschrijving</td> <td><textarea name="description" cols="34"></textarea></td> </tr> <tr> <td>Album</td> <td> <select name="album"> <?php while($album_rij = mysql_fetch_array($album)){ ?> <option value="<?php echo $album_rij[0] ?>"><?php echo $album_rij[1] ?></option> <?php } ?> </select> </td> </tr> <tr> <td>Selecteer een foto</td> <td><input type="file" name="file" size="45" /></td> </tr> <tr> <td></td> <td><input type="submit" value="Foto toevoegen" name="send" /></td> </tr> </table> </form>
Jump To Top of Thread