Aller au contenu

rottman

Webmaster Régulier
  • Compteur de contenus

    80
  • Inscrit(e) le

  • Dernière visite

Messages postés par rottman

  1. 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;
    }
    ?>

  2. Il est possible d'exploiter l'erreur 404 pour faire de l'url rewriting chez free

    Un exemple :

    dans .htaccess :

    ErrorDocument 404 /url-rewriting.php

    dans url-rewriting.php :

    <?php 
    $url = pathinfo("$REQUEST_URI");
    $variable_avec_tiret = $url["basename"];
    $variable_sans_tiret = str_replace( "-", " " , $variable_avec_tiret);
    header("HTTP/1.0 200 OK");
    header("Location: index.php?page=".$variable_sans_tiret."");
    ?>

    Dans cet exemple, si l'on va à la page tonsite.fr/je-sais-pas

    cette url sera réécrite en index.php?page=je%20sais%20pas

    Cela marche pafaitement ;)

×
×
  • Créer...