upload_dir.$this->file_copy; $thumb = $this->thumb_folder.$this->file_copy; $foto = $this->foto_folder.$this->file_copy; $this->get_img_size($filename); if ($this->y_size > $this->x_size) { $this->img_rotate($filename); $this->get_img_size($filename); // repeat this because the img is changed } if ($this->x_size > 640) { $this->thumbs($filename, $foto, 640, 80); } $this->thumbs($filename, $thumb, 240, 85); $this->del_temp_file($filename); } function get_img_size($file) { $img_size = getimagesize($file); $this->x_size = $img_size[0]; $this->y_size = $img_size[1]; } function img_rotate($wr_file) { $new_x = $this->y_size; $new_y = $this->x_size; $src_img = imagecreatefromjpeg($wr_file); $rot_img = imagerotate($src_img, 90, 0); $new_img = imagecreatetruecolor($new_x, $new_y); imageantialias($new_img, TRUE); imagecopyresampled($new_img, $rot_img, 0, 0, 0, 0, $new_x, $new_y, $new_x, $new_y); imagejpeg($new_img, $this->upload_dir.$this->file_copy, 85); } function thumbs($file_name_src, $file_name_dest, $weight, $quality=80) { $size = getimagesize($file_name_src); $w = number_format($weight, 0, ',', ''); $h = number_format(($size[1]/$size[0])*$weight,0,',',''); $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); $src = imagecreatefromjpeg($file_name_src); imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); imagejpeg($dest, $file_name_dest, $quality); } function del_temp_file($file) { $delete = @unlink($file); clearstatcache(); if (@file_exists($file)) { $filesys = eregi_replace("/","\\",$file); $delete = @system("del $filesys"); clearstatcache(); if (@file_exists($file)) { $delete = @chmod ($file, 0775); $delete = @unlink($file); $delete = @system("del $filesys"); } } } } $DOCUMENT_ROOT = '.'; $max_size = 1024*1536; // the max. size for uploading define("MAX_SIZE", $max_size); $foto_upload = new Foto_upload; $foto_upload->upload_dir = $DOCUMENT_ROOT."/files/tmp/"; // "files" is the folder for the uploaded files (you have to create these folder) $foto_upload->thumb_folder = $DOCUMENT_ROOT."/files/thumbs/"; $foto_upload->foto_folder = $DOCUMENT_ROOT."/files/fotos/"; $foto_upload->extensions = array(".jpg"); // specify the allowed extension(s) here if (isset($_POST['Submit']) && $_POST['Submit'] == "Upload") { $foto_upload->the_temp_file = $_FILES['upload']['tmp_name']; $foto_upload->the_file = $_FILES['upload']['name']; $foto_upload->http_error = $_FILES['upload']['error']; $foto_upload->rename_file = true; $foto_upload->replace = "n"; $foto_upload->do_filename_check = "n"; if ($foto_upload->upload()) { $foto_upload->process_image(); } } $error = $foto_upload->show_error_string(); ?> Photo-upload form

Photo-upload form