Salut,
Je veux lire les variable envoyées par la méthode PUT.
J'utilise ce lien:
http://www.lornajane.net/posts/2008/...-Data-from-PHP.
Voici le code:
j'utilise l'extension Firefox "poster" pour exécuter cet exemple. GET
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?php if($_SERVER['REQUEST_METHOD'] == 'GET') { echo "this is a get request\n"; echo $_GET['fruit']." is the fruit\n"; echo "I want ".$_GET['quantity']." of them\n\n"; } elseif($_SERVER['REQUEST_METHOD'] == 'PUT') { echo "this is a put request\n"; parse_str(file_get_contents("php://input"),$post_vars); echo $post_vars['fruit']." is the fruit\n"; echo "I want ".$post_vars['quantity']." of them\n\n"; } ?>
marche bien mais pas PUT, file_get_contents("php://input")
retourne une chaine vide.
J'ai trouvé un bug qi est relié mais cela a été réglé j'imagine: https://bugs.php.net/bug.php?id=51592
J'utilise xampp sur win7 :
+ Apache 2.2.17
+ MySQL 5.5.8 (Community Server)
+ PHP 5.3.5 (VC6 X86 32bit) + PEAR)
Toute suggestion est la bienvenue.
Merci
Partager