Hi Volka,
The file is 1.2 MB large.
The code is contained in two classes.
1. fileupload which handles the upload process, which inprinciple is this function(the dutch texts are just error messages):
Code: Select all
function Upload() {
if (($this->upl_file != -1) && ($this->new_filename != -1) && ($this->copy_to != -1)) {
if (!($this->upl_file == "none" || $this->upl_file=="")) {
if (!file_exists($this->copy_to . "/" . $this->new_filename)) {
$this->CorrectFilename();
if ($this->MustHaveType != "") {
if ($this->MustHaveType !=$this->IsType) {$typeok = false;} else {$typeok = true;}
} else {
$typeok = true;
}
if ($typeok == false) {
$this->error = "Het bestand is niet van het type " . $this->MustHaveType . " en is daarom niet opgeslagen.";
} else {
if (@copy($this->upl_file,$this->copy_to . "/" . $this->new_filename)) {
if (file_exists($this->copy_to . "/" . $this->new_filename)) {
return true;
} else {
$this->error = "Er is iets mis gegaan met het opslaan van het bestand.";
return false;
}
} else {
$this->error = "Het bestand is niet goed verstuurd en is daarom niet opgeslagen.";
return false;
}
}
} else {
$this->error = "Het bestand dat u zojuist heeft verstuurd bestaat al en is daarom niet opgeslagen.";
return false;
}
} else {
return false;
}
} else {
return false;
}
}
2. The image resize:
Code: Select all
function Resize($NewImageWidth="",$NewImageWidthSmall="",$OnlyLarger=0) {
copy($this->urlafbeelding,$this->tmpurlafbeelding);
$size = GetImageSize ("$this->tmpurlafbeelding");
$ImageWidth = $size[0];
$ImageHeight = $size[1];
if ($OnlyLarger == 0) {
$resize_img = true;
} else {
if ($ImageWidth > $NewImageWidth) {
$resize_img = true;
} else {
$resize_img = false;
}
}
if ($resize_img) {
$NewImageHeight = round(($NewImageWidth / $ImageWidth) * $ImageHeight);
$src_img = ImageCreateFromJPEG("$this->tmpurlafbeelding");
if ($this->method != 0) {
$dst_img = imagecreatetruecolor($NewImageWidth,$NewImageHeight);
imageCopyResampled($dst_img,$src_img,0,0,0,0,$NewImageWidth,$NewImageHeight,$ImageWidth,$ImageHeight);
} else {
$dst_img = imagecreate($NewImageWidth,$NewImageHeight);
imageCopyResized($dst_img,$src_img,0,0,0,0,$NewImageWidth,$NewImageHeight,$ImageWidth,$ImageHeight);
}
ImageJPEG($dst_img,"$this->urlafbeelding",100);
}
if ($this->urlafbeelding_small != "") {
$NewImageHeight = round(($NewImageWidthSmall / $ImageWidth) * $ImageHeight);
$src_img = imagecreatefromjpeg("$this->tmpurlafbeelding");
if ($this->method != 0) {
$dst_img = imagecreatetruecolor($NewImageWidthSmall,$NewImageHeight);
imageCopyResampled($dst_img,$src_img,0,0,0,0,$NewImageWidthSmall,$NewImageHeight,$ImageWidth,$ImageHeight);
} else {
$dst_img = imagecreate($NewImageWidthSmall,$NewImageHeight);
imageCopyResized($dst_img,$src_img,0,0,0,0,$NewImageWidthSmall,$NewImageHeight,$ImageWidth,$ImageHeight);
}
Imagejpeg($dst_img, $this->urlafbeelding_small,100);
}
unlink($this->tmpurlafbeelding);
}
[mod_edit changed Code: Select all
][/size]
Hope this clarifies something.
Greetz Jolly.