-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpCode
More file actions
65 lines (55 loc) · 1.4 KB
/
PhpCode
File metadata and controls
65 lines (55 loc) · 1.4 KB
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
56
57
58
59
60
61
62
63
64
65
<?php
require '../bootstrap/init.php';
$response = array();
$image = $_FILES["file"];
if($image!="")
{
for($i=0;$i<1;$i++)
{
$file_name=$_FILES['file']['name'][$i];
$file_size=$_FILES['file']['size'][$i];
$file_error=$_FILES['file']['error'][$i];
$file_ext=explode('.',$file_name);
$file_ext=strtolower(end($file_ext));
$allowed=array('jpeg','jpg','png','gif');
if(in_array($file_ext,$allowed))
{
if($file_error===0)
{
/*if($file_size<=2097152)
{*/
$file_name_new=uniqid('',true).'.'.$file_ext;
$file_name_new = time(). "_".$file_name;
$file_destination='../assests/adhaar_img/'.$file_name_new;
if(move_uploaded_file($_FILES['file']['tmp_name'][$i],$file_destination))
{
$response['success'] = '1';
$response['message'] = 'Image uploaded!';
}
else
{
$response['success'] = '0';
$response['message'] = 'Image not uploaded!';
}
/*}
else
{
$response['success'] = '0';
$response['message'] = 'Image size to large!';
}*/
}
}
else
{
$response['success'] = '0';
$response['message'] = 'Invalid file';
}
}
}
else
{
$response['success'] = '0';
$response['message'] = 'Request perameter invalid!';
}
echo json_encode($response);
?>