File size: 1,283 Bytes
0ec97f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

	require './config/app.php';
	require './config/upload.php';

	$options = array(
		'upload_path' => './uploads/images/', // set upload folder
		'thumb_path' => './uploads/thumb/', // set thumbnail folder
		'extension' => array('jpeg', 'jpg', 'png', 'gif', 'webp'), //allowed extension
		'mime_type' => array('image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp'), //allowed mime types
	);

	$upload = new hcgImageUploads($options);

	$upload->do_upload('file_image'); //input file name

	/*
	    if success upload return data

	    {
	    "status": "success",
	    "image_data": {
	         "name": "35888G9722W5UNB.jpg",
	         "type": "jpg",
	         "size": 22545,
	         "size_format": "22.02 KB",
	         "width": 480,
	         "height": 549,
	         "thumb": "/uploads/thumb/2020/08/26/35888G9722W5UNB.png",
	         "url": /uploads/images/2020/08/26/21/35888G9722W5UNB.jpg"
	        }
	    }

	    if error

	    {
	     "status": "error",
	     "msg": "error msg",
	     "error_type": ""
	    }
	*/

	// here you can hide some result
	// $hide_result = array('thumb','width',height);

	$hide_result = array('thumb');

	$result = $upload->get_result($hide_result);

	echo json_encode($result);
}

?>