|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
<?php // $Id: document.php 18976 2009-03-11 22:17:03Z yannoo $
|
|
|
|
|
<?php // $Id: document.php 19016 2009-03-12 21:43:04Z herodoto $
|
|
|
|
|
/* |
|
|
|
|
============================================================================== |
|
|
|
|
Dokeos - elearning and course management software |
|
|
|
@ -649,8 +649,36 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY |
|
|
|
|
// upload dir |
|
|
|
|
$upload_dir = api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/'; |
|
|
|
|
|
|
|
|
|
// move the uploaded file to the home folder |
|
|
|
|
$result= @move_uploaded_file($_FILES['template_image']['tmp_name'], $upload_dir.$new_file_name); |
|
|
|
|
|
|
|
|
|
// resize image to max default and end upload |
|
|
|
|
require_once (api_get_path(LIBRARY_PATH).'image.lib.php'); |
|
|
|
|
$temp = new image($_FILES['template_image']['tmp_name']); |
|
|
|
|
$picture_infos=getimagesize($_FILES['template_image']['tmp_name']); |
|
|
|
|
|
|
|
|
|
$max_width_for_picture = 100; |
|
|
|
|
|
|
|
|
|
if ($picture_infos[0]>$max_width_for_picture) |
|
|
|
|
{ |
|
|
|
|
$thumbwidth = $max_width_for_picture; |
|
|
|
|
if (empty($thumbwidth) or $thumbwidth==0) { |
|
|
|
|
$thumbwidth=$max_width_for_picture; |
|
|
|
|
} |
|
|
|
|
$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]); |
|
|
|
|
|
|
|
|
|
$temp->resize($thumbwidth,$new_height,0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$type=$picture_infos[2]; |
|
|
|
|
|
|
|
|
|
switch (!empty($type)) |
|
|
|
|
{ |
|
|
|
|
case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name); |
|
|
|
|
break; |
|
|
|
|
case 3 : $temp->send_image('PNG',$upload_dir.$new_file_name); |
|
|
|
|
break; |
|
|
|
|
case 1 : $temp->send_image('GIF',$upload_dir.$new_file_name); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|