0

I am currently working on resizing images with php for my site. So far everything is working well I manage to upload my images, resize them and just as I want despite that special characters appear on my page without me knowing why... I would like to know then why it displays these characters to me when I get the desired result and if it was possible to at least hide these characters. Thank you.

The function works perfectly when I test it outside except that it doesn't display the special characters

send.php (can be useful)

 <form enctype="multipart/form-data" action="fileupload.php" method="post">
 <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
 <input type="file" name="monfichier" multiple>

fileupload.php

function collage($cheminImage){
$dest = imagecreatefrompng('blank.png');
if ($cheminImage == "/.png/") {
$src = imagecreatefrompng($cheminImage);
}
else $src = imagecreatefromjpeg($cheminImage);

$size_src = getimagesize($cheminImage);
$largeur = $size_src[0];
$hauteur = $size_src[1];
$h_milieu = 150-($hauteur/2);
$l_milieu = 150-($largeur/2);

imagealphablending($dest, false);
imagesavealpha($dest, true);

imagecopymerge($dest, $src, $l_milieu, $h_milieu, 0, 0, $largeur, $hauteur, 100);

imagepng($dest);
ImagePng ($dest, $cheminImage);
imagedestroy($src);
}
collage($cheminImage);
June
  • 27
  • 6

1 Answers1

0

If you want to display the image you created, you need to set your headers correct.

Use header funcion to do so, check the documentation, also there's a useful way to use it which is answered here, check the accepted answer.

CeritT
  • 522
  • 3
  • 12
  • Thanks for answer but that's not what I want.. I just need PHP to paste my image into another one and it has saved it on my hard drive, which it does very well, yet it displays special characters that I can't make disappear. – June Apr 08 '19 at 12:19
  • Maybe we should see your full code to understand what you are trying to do there but before that, when you use `imagepng()` with only one parameter like in `imagepng($dest);` it outputs the image data directly to the browser which results in showing those weird characters. – CeritT Apr 08 '19 at 22:50
  • @JuneW glad i could help. – CeritT Apr 14 '19 at 08:11