Se connecter avec
S'enregistrer | Connectez-vous

[PHP] - Les variables globales et manipulation de fichier

Dernière réponse : dans Programmation

Moi les variables global j'ai jamais rien compris, donc j'avais resolu le probleme en les desactivant mais la dernierement je bosse avec un developpeur qui en as besoin pour ces scripts du coup j'ai un script que je dois convertir pour qu'il fonction avec les variables globales


  1. LE FORMULAIRE
  2.  
  3. <input name="photo" type="file" id="photo" size="37">
  4.  
  5.  
  6. LE CODE
  7.  
  8. <?
  9. if (is_uploaded_file($photo))
  10. {redimensionner($photo,"../photo/".$img.".jpg",120,120);}
  11. ?>
  12.  
  13.  
  14. LA FONCTION
  15.  
  16. <?
  17. function redimensionner($src, $dst, $h, $w)
  18. {
  19. $img = ImageCreateFromJPEG($src);
  20. $img_w = ImageSX($img);
  21. $img_h = ImageSY($img);
  22. // Calcul nouvelle taille
  23. $w_ratio = $w / $img_w;
  24. $h_ratio = $h / $img_h;
  25.  
  26. if ( ($img_w <= $w) && ($img_h <= $h) ) {
  27. $tn_w = $img_w;
  28. $tn_h = $img_h;
  29. }
  30. else if (($w_ratio * $img_h) < $h) {
  31. $tn_h = ceil($w_ratio * $img_h);
  32. $tn_w = $w;
  33. }
  34. else {
  35. $tn_w = ceil($h_ratio * $img_w);
  36. $tn_h = $h;
  37. }
  38.  
  39. $nimg = ImageCreateTrueColor($tn_w, $tn_h);
  40. imagecopyresampled($nimg, $img, 0,0,0,0, $tn_w,$tn_h, $img_w, $img_h);
  41. ImageJPEG($nimg, $dst,100);
  42. }
  43. ?>


a mon avis la fonction ne change pas, je dirai que seul la partie code doit surement integrer quelque chose du type

$_FILES['photo']['name']


mais la je bloque
Lassé par la pub ? Créez un compte
Lassé par la pub ? Créez un compte