function processSingleImage() { $response = ["success" => 0, "sample" => "", "msg" => "Missing fields", "predictions" => ""]; if (isset($_FILES["file"]["name"]) && file_exists($_FILES["file"]["tmp_name"])) { $target_file = DIR_SIGNS_CLASSIFY_ONE . basename($_FILES["file"]["name"]); $image_file_type = pathinfo($target_file, PATHINFO_EXTENSION); $check = getimagesize($_FILES["file"]["tmp_name"]); if ($check !== false) { $msg = "File is an image - " . $check["mime"] . "."; $success = 1; } else { $msg = "File is not an image."; $success = 0; } // Check file size if ($_FILES["file"]["size"] > 500000) { $msg = "Sorry, your file is too large."; $success = 0; } // Check if file already exists if (file_exists($target_file)) { $msg = "Sorry, file already exists."; $success = 0; } // Allow certain file formats if ($image_file_type != "jpg" && $image_file_type != "png" && $image_file_type != "jpeg" && $image_file_type != "gif") { $msg = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $success = 0; } if ($success) { $file_name = DIR_SIGNS_CLASSIFY_ONE . uniqid('img_') . "." . $image_file_type; saveUploadedImage($file_name); $response["sample"] = 'http://arcos.io/cv_tools/' . $file_name; try { $response['predictions'] = classifyOne($response["sample"]); $success = 1; } catch (ServerException $e) { $response["success"] = 0; $response["msg"] = "Image not found"; } } $response["success"] = $success; $response["msg"] = $msg; } else { if (isset($_POST['url']) && !filter_var($_POST['url'], FILTER_VALIDATE_URL) === false) { $url = $_POST['url']; $response['sample'] = $url; try { $response['predictions'] = classifyOne($response['sample']); $response["success"] = 1; } catch (ServerException $e) { $response["success"] = 0; $response["msg"] = "Image not found"; } } } return $response; }
case 'new': editImage($option, 0); break; case 'batchupload': HTML_RSGallery::RSGalleryHeader('', JText::_('Upload ZIP-file')); batchupload($option); HTML_RSGallery::RSGalleryFooter(); break; case 'save_batchupload': save_batchupload(); break; case 'upload': uploadImage($option); break; case 'save_upload': saveUploadedImage($option); break; case 'edit': editImage($option, $cid[0]); break; case 'editA': editImage($option, $id); break; case 'save': saveImage($option); break; case 'remove': removeImages($cid, $option); break; case 'publish': publishImages($cid, 1, $option);