Hej alle sammen, dette script virker helt fint i firefox, men det virker overhoved ikke i IE.
Her er fejlen i IE:
Sorry, but the file you uploaded was not a GIF, JPG, or .PNG file.
Warning: imagesx(): supplied argument is not a valid Image resource in /home/hswestergaard.dk/web/www/_artikel/pic_upload_ret.php on line 50
Warning: imagesy(): supplied argument is not a valid Image resource in /home/hswestergaard.dk/web/www/_artikel/pic_upload_ret.php on line 51
Warning: Division by zero in /home/hswestergaard.dk/web/www/_artikel/pic_upload_ret.php on line 52
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/hswestergaard.dk/web/www/_artikel/pic_upload_ret.php on line 55
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/hswestergaard.dk/web/www/_artikel/pic_upload_ret.php on line 56
Sorry, but the file you uploaded was not a GIF, JPG, or .PNG file.
her er koden:
<?php
Session_Start();
if ($_SESSION["login"] !== lala) {
header("Refresh: 1; URL=index.php");
echo "Du har ikke adgang";
} else {
}
$konfiguration["upload_bibliotek"] = "./upload/";
$konfiguration["max_stoerrelse"] = "700000";
$fra = $_FILES["upfil"]["tmp_name"];
$fra2 = $_FILES["upfil"]["name"];
$til = $konfiguration["upload_bibliotek"] . $_FILES["upfil"]["name"];
$fil_stoerrelse = filesize($fra)/1024;
if($fil_stoerrelse > $konfiguration["max_stoerrelse"]) {
die("Filen er for stor");
}
if(function_exists("move_uploaded_file")) {
move_uploaded_file($fra, $til);
$newfilename = "".rand(1, 1000000)."".$fra2."";
$newfilename2 = "upload/". $newfilename ."";
rename($til, $newfilename2);
} else {
copy($fra, $til);
rename($til, $newfilename2);
}
$pic = "upload/". $newfilename ."";
$thumb = "upload/small". $newfilename ."";
Thumb($pic, $thumb);
function Thumb($sourcefile, $targetfile) {
$size = 230;
switch ($_FILES['upfil']['type']) {
case "image/gif":
$source_id = imageCreateFromGIF($sourcefile);
break;
case "image/jpeg":
$source_id = imageCreateFromJPEG($sourcefile);
break;
case "image/png":
$source_id = imageCreateFromPNG($sourcefile);
break;
default:
echo "Sorry, but the file you uploaded was not a GIF, JPG, or .PNG file.";
}
#$source_id = $format;
#$source_id = imageCreateFromJPEG($sourcefile);
$source_x = imagesx($source_id);
$source_y = imagesy($source_id);
$delta = $size/max($source_x, $source_y);
$dest_x = round($source_x*$delta);
$dest_y = round($source_y*$delta);
$target_id=imagecreatetruecolor($dest_x, $dest_y);
imagecopyresampled($target_id,$source_id,0,0,0,0, $dest_x,$dest_y, $source_x,$source_y);
touch($targetfile);
switch ($_FILES['upfil']['type']) {
case "image/gif":
imagegif($target_id,$targetfile,100);
break;
case "image/jpeg":
imagejpeg($target_id,$targetfile,100);
break;
case "image/png":
imagepng($target_id,$targetfile,100);
break;
default:
echo "Sorry, but the file you uploaded was not a GIF, JPG, or .PNG file.";
}
}
$_SESSION['picname'] = $newfilename;
$_SESSION['picnamesmall'] = "small".$newfilename."";
header("Location: tilfoj_artikel.php?id=14");
?>
Marc Zacho
www.senia.dk - www.hcparty.dk