增加图片处理

hotfix/远程访问多媒体中心
LMR 7 years ago
parent 98f000e4c9
commit dfca3b72f2

@ -333,6 +333,7 @@ class Info_amp extends CI_Controller
}
public function handel_png_source() {
//ini_set('memory_limit', '50M');
$png_base64 = $this->input->post('png_base64');
//$png_base64 = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$file = md5($png_base64).'.jpg';
@ -360,7 +361,59 @@ class Info_amp extends CI_Controller
}
}
public function handel_image_source() {
@ini_set('memory_limit', '256M');
$file = $_FILES['file'];
if (!$file) {
echo(json_encode(array(
'status' => 'error',
'msg' => "图片上传失败。"
)));
return;
}
//转移文件
$md5_file = md5($file['name'].$file['size']);
//ext
$ext = mb_strtolower(strrchr($file["name"],'.'));
if ($ext != '.jpg') {
echo(json_encode(array(
'status' => 'error',
'msg' => '只能接收(.jpg)图片。'
)));
return;
}
$md5_name = $md5_file.$ext;
//临时docx文件
$image_path = realpath('../cht-system/views/information/word_img').'/'.basename($md5_name);
$html = 'to use mammoth';
if (move_uploaded_file($file['tmp_name'], $image_path)) {
//图片处理
$im = imagecreatefromjpeg($image_path);
imagejpeg($im, $image_path);
imagedestroy($im);
$size = getimagesize($image_path);
if($size) {
echo(json_encode(array(
'status' => 'success',
'path' => '/information-view/information/word_img/'.$md5_name,
'width' => $size[0],
'height' => $size[1]
)));
} else {
echo(json_encode(array(
'status' => 'error'
)));
}
} else {
echo(json_encode(array(
'status' => 'error',
'msg' => "图片文件解析失败。"
)));
}
}
public function handel_word_source() {
@ini_set('memory_limit', '256M');
$file = $_FILES['file'];
if (!$file) {
echo(json_encode(array(

Loading…
Cancel
Save