emh php's upload function er sådan set lige glad hvad fil-type det er, så skulle ik være det store problem
du kan lave et array med de fil-typer du vil lade brugeren uploade..
noget ala det her, er ikke testet.
- <form action="" method="post" enctype="multipart/form-data">
- <p>Pictures:
- <input type="file" name="pictures[]" />
- <input type="file" name="pictures[]" />
- <input type="file" name="pictures[]" />
- <input type="submit" name="doSubmit" value="Send" />
- </p>
- </form>
- $ext = array("jpg", "gif", "png");
- if(isset($_POST["doSubmit"]){
- foreach ($_FILES["pictures"]["error"] as $key => $error) {
- if ($error == UPLOAD_ERR_OK) {
- $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
- $name = $_FILES["pictures"]["name"][$key];
- if(in_array(array_pop(explode(".", $name)), $ext){
- move_uploaded_file($tmp_name, "data/$name");
- }else{
- //ikke godkedt fil-type
- }
- }
- }
- }