i have this basic upload script which will upload an image inside "images/" folder.
It is very simple, and works with only one file
the problem is that it will work only with JPEG files Sad If i try to upload with a GIF image, the result will be a black image
could anyone help me to make it work with gif files?
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<?php
include("bands.php");
?><br>
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<br>
<button name="submit" type="submit" class="submitButton">AJOUTER L'IMAGE</button>
</form>
<?php
$band = $_POST['band'];
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagenamz = $_FILES['new_image']['name'];
/* $numz = time();
$nums = date('dmy');
$num1 = "$nums" . $numz;
$band = $_POST['band'];
echo $band;
echo "<hr>";
$imagename = "$band" . $num1;
echo $imagename;
*/
echo "L'image a été ajouté dans l'album photos de <b>$band</b><hr><br>";
$originalname = $_FILES['new_image']['name'];
$date = date('dmy');
$imagename = "$band" . "_" . $date . "_" . $originalname;
echo $imagename;
$source = $_FILES['new_image']['tmp_name'];
$target = "images/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "images/" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 800;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "images/sml_" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 150;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
echo "<img src='images/".$imagepath."'><br>";
echo "Thumbnail: <img src='images/sml_".$imagepath."'>";
}
}
?>