Avec un formulaire du type :
<form enctype="multipart/form-data" action="upload.php" method="post"> <input name="image" type="file" /> <input type="submit" value="Ok" /> </form>
et une page upload.php comme ça :
<?php $MAX_FILE_SIZE = 10000; // taille max $folder = "./"; // destination $allowed_types = array("image/png", "image/bmp", "image/gif", "image/jpeg", "image/jpg"); $fname = $HTTP_POST_FILES['image']['name']; $ftype = $HTTP_POST_FILES['image']['type']; $fsize = $HTTP_POST_FILES['image']['size']; $ftmp = $HTTP_POST_FILES['image']['tmp_name']; if(!in_array($ftype, $allowed_types)){$error = 1;} if($fize > $MAX_FILE_SIZE){$error = 2;} if(copy($ftmp,''.$folder.''.$fname.'')) {$error = 0;} switch($error){ case'0': echo("Upload OK"); break; case'1': echo("Format non autorisé"); break; case'2': echo("Taille maxi dépassée"); break; } ?>