private function save_file() { try { $tmp_name = $_FILES['image_file']['tmp_name']; $origin_filename = $_FILES['image_file']['name']; $pathinfo = pathinfo($origin_filename); $image_nm = strtolower($pathinfo['filename']); $image_ext = strtolower($pathinfo['extension']); $image_name = array_sum(explode(' ', microtime())) . "." . $image_ext; $imagefull = SlideshowJedoGallery::uploads_slideshowjedogallery_path() . $image_name; $issafe = false; $mimes = get_allowed_mime_types(); foreach ($mimes as $type => $mime) { if (strpos($type, $image_ext) !== false) { $issafe = true; } } if ($issafe) { if (is_uploaded_file($tmp_name)) { if (move_uploaded_file($tmp_name, $imagefull)) { $thumbimage = wp_get_image_editor($imagefull); if (!is_wp_error($thumbimage)) { $thumbimage->resize(250, 250, true); $thumbimage->save(SlideshowJedoGallery::thumbnails_slideshowjedogallery_path() . $image_name); } else { throw new Exception(__CLASS__ . " is_wp_error error code[" . $thumbimage->get_error_code() . "] " . $thumbimage->get_error_message()); wp_die(); } } else { throw new Exception(__CLASS__ . " move_uploaded_file error "); wp_die(); } } else { throw new Exception(__CLASS__ . " is_uploaded_file error "); wp_die(); } } else { throw new Exception(__CLASS__ . " mime type error "); wp_die(); } return array("image_name" => $image_name, "image_url" => SlideshowJedoGallery::uploads_slideshowjedogallery_url() . $image_name, "origin_filename" => $origin_filename); } catch (Exception $e) { echo " slide save_file " . $e->getMessage(); wp_die(); } }