|
La Communauté Webmaster 
| Pages: [1] |
 |
|
|
|
Auteur |
Sujet: [Résolu]Upload et redimention d'image (Lu 915 fois) |
|
 |
[Résolu]Upload et redimention d'image
« sur: le 30-09-2008 a 17:24:21 » |
|
Polourdix
Membre récent

Hors-Ligne
Messages: 5

Je suis un lama!
|
Bonjour, j'ai un script php qui upload puis redimentionne une image:
---------------------------------------------------------------------------------------------
<?php
// ///////////////////////////////////////////////////////////////////////////////////// // Tuto ici GD: http://www.phpdebutant.org/article111.php // /////////////////////////////////////////////////////////////////////////////////////
if(isset($_FILES['photo'])) { $dossier = 'imgs/'; $fichier = basename($_FILES['photo']['name']); $vrFichier = "imgs/".$fichier;
$vrIMGdestination = "imgs/cop_".$fichier;
$extension = strrchr($vrFichier,'.'); // On récupére l'extension du fichier uploader
/////////////////////////////////////////////////////////////////////////////////////// // Pour ajouter des extension c'est ici: ////////////////////////////////////////
if ($extension == ".jpg" or $extension == ".jpeg") { header("Content-Type: image/jpeg"); } // Indispenssable pour le téléchargement de l'image redimentionner. if ($extension == ".gif") { header("Content-Type: image/gif"); } // Indispenssable pour le téléchargement de l'image redimentionner. if ($extension == ".tif" or $extension == ".tiff") { header("Content-Type: image/tiff"); } // Indispenssable pour le téléchargement de l'image redimentionner. if ($extension == ".png") { header("Content-Type: image/png"); } // Indispenssable pour le téléchargement de l'image redimentionner.
if ($extension == ".jpg" or $extension == ".jpeg" or $extension == ".gif" or $extension == ".tif" or $extension == ".tiff" or $extension == ".png")
///////////////////////////////////////////////////////////////////////////////////////
{
if(move_uploaded_file($_FILES['photo']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné... { //header("Content-Disposition: attachment; filename=".$vrIMGdestination); // Ici on lance le téléchargent de l'image redimentionnée.
/////////////////////////////////////////////////////////////////////////////////////// // Redimentionement de l'image: ///////////////////////////////
$vrTailleIMG = GetImageSize ($vrFichier); $vrLargIMG = "$vrTailleIMG "; $vrHautIMG = "$vrTailleIMG[1]";
if ($vrLargIMG > $vrHautIMG) {
$largeurDestination = 640; $hauteurDestination = 480;
$vrIMGdestination2 = ImageCreate ($largeurDestination, $hauteurDestination); $vrFichier2 = imagecreatefromjpeg($vrFichier); //$couleur_fond = ImageColorAllocate ($vrIMGdestination2, 255, 0, 0);
ImageCopyResampled($vrIMGdestination2, $vrFichier2, 0, 0, 0, 0, $largeurDestination, $hauteurDestination, $vrLargIMG, $vrHautIMG); ImageJpeg ($vrIMGdestination2);
} else {
echo "image verticale";
}
///////////////////////////////////////////////////////////////////////////////////////
readfile($vrIMGdestination); // Ici on lance le téléchargent de l'image redimentionnée. //unlink($vrIMGdestination); // Ici on supprime l'image une foi quelle à été télécharger. unlink($vrFichier); // Ici on supprime l'image une foi quelle à été télécharger. exit(); } else { // Si l'image n'a pas été uploader. echo '!!! Impossible d\'envoyer le fichier selectionné'; echo ("<meta http-equiv='Refresh' content='2;URL=index.php'>"); // Redirection ver le formulaire si l'image n'a pas été uploader. }
} else { echo "Ce n\'est pas une image valide que vous essayer de redimentioner, ou ce type d\'image ne peut être redimentionner ici ou bien ce n'est même pas un image"; echo ("<meta http-equiv='Refresh' content='5;URL=index.php'>"); // Redirection ver le formulaire si l'image n'a pas été uploader.
} }
?>
---------------------------------------------------------------------------------------------
le souci c'est que li'mage redimentionner n'est pas créer, voyer vous l'erreur ? |
|
|
|
|
|
|
 |
Re:ulpoad et redimention d'image
« Répondre #1 sur: le 20-10-2008 a 13:02:23 » |
|
|
|
|
| Pages:
[1] |
|
|
|
| |
|
|