test / upload.php
0x1668's picture
Upload 6 files
0ec97f1 verified
Raw
History Blame Contribute Delete
1.28 kB
<?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);
}
?>