bonsoir
je galère avec un script de redimensionnement d'image ,j'ai une erreur php du genre:
Fatal error : Allowed memory size of 8388608 bytes exhausted (tried to allocate 10700 bytes) in
C:\wamp\www\photo_upload\ajout_photo.php on line 32
en plus , l'envoi de photo sur mon site hébergé chez free avec le même script php ,de chez moi ca fonctionne à merveille mais chez d'autre personne ca ne marche pas,il y a la même erreur comme ci-dessus
c'est pour ca que je l'ai testé sur wamp pour voir
je n'y comprend plus rien au secours
voici mon code:
<?php
session_start();
if (isset($_FILES['choix_photo']) AND isset($_POST['nom_photo'])) // Si les variables existent
{
if ($_FILES['choix_photo'] != NULL AND $_POST['nom_photo'] != NULL) // Si on a quelque chose à enregistrer
{
$_photo= "photos/".$_POST['nom_photo'].".JPG";
$_photo_mini= "photos/mini_".$_POST['nom_photo'].".jpg";
$_extension_valide= array("JPG","jpg");
$_extension_upload= substr(strrchr($_FILES['choix_photo']['name'],'.'),1);
$_ip= $_SERVER['REMOTE_ADDR'];
if(is_file($_photo) == FALSE
AND in_array($_extension_upload,$_extension_valide))
{
move_uploaded_file($_FILES['choix_photo']['tmp_name'],$_photo);
//-------------redim_image----------------------------------
$percent = 0.27;
$percent2 = 0.36;
$percent_mini = 0.05;
// Calcul des nouvelles dimensions
list($width, $height) = getimagesize($_photo);
$new_width = $width * $percent;
$new_height = $height * $percent;
$new_width2 = $width * $percent2;
$new_height2 = $height * $percent2;
$new_width_mini = $width * $percent_mini;
$new_height_mini = $height * $percent_mini;
// Redimensionnement
if(($width>2048 AND $height>1536) OR ($width>1536 AND $height>2048))
{
$_destination = imagecreatetruecolor($new_width, $new_height); //photo vide
$_source = imagecreatefromjpeg($_photo); // photo source <- ligne 32 de l'erreur
imagecopyresampled($_destination, $_source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Affichage
imagejpeg($_destination, $_photo, 100);
imagedestroy($_source);
//---------image mini-------------------
$_destination_mini = imagecreatetruecolor($new_width_mini, $new_height_mini);//photo vide
$_source_mini = imagecreatefromjpeg($_photo);//photo source
imagecopyresampled($_destination_mini, $_source_mini, 0, 0, 0, 0, $new_width_mini, $new_height_mini, $new_width, $new_height);
// Affichage
imagejpeg($_destination_mini, $_photo_mini, 100);
imagedestroy($_source_mini);
//----------------------------------------------------------
else
{
$_destination = imagecreatetruecolor($new_width2, $new_height2);
$_source = imagecreatefromjpeg($_photo);
imagecopyresampled($_destination, $_source, 0, 0, 0, 0, $new_width2, $new_height2, $width, $height);
// Affichage
imagejpeg($_destination, $_photo, 100);
imagedestroy($_source);
//---------image mini----------------------
$_destination_mini = imagecreatetruecolor($new_width_mini, $new_height_mini);
$_source_mini = imagecreatefromjpeg($_photo);
imagecopyresampled($_destination_mini, $_source_mini, 0, 0, 0, 0, $new_width_mini, $new_height_mini, $new_width2, $new_height2);
// Affichage
imagejpeg($_destination_mini, $_photo_mini, 100);
imagedestroy($_source_mini);
//----------------------------------------------------------
}
}else{header('location:info_redim_image.php'); exit;}
}
}
if($_FILES['choix_photo'] == NULL)
{header('location:info_redim_image.php'); exit;}
header('location:photos_parents.php');
exit;
?>
Afficher la suite