-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuploadfile.php
More file actions
175 lines (57 loc) · 1.82 KB
/
uploadfile.php
File metadata and controls
175 lines (57 loc) · 1.82 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
Creation Date : 2013/02/27
Description: Class include the functions related to file upload, delete.
**********************************************************************
*/
class uploadFile{
function uploadImage($file = array())
{
$response = array();
if(!empty($file['tmp_name']))
{
$filecheck = basename($file['name']);
$ext = strtolower(substr($filecheck, strrpos($filecheck, '.') + 1));
$file_type = $file["type"];
$file_size = $file["size"];
if (($file_type == "image/jpg" || $file_type == "image/jpeg" || $file_type == "image/gif" || $file_type == "image/png") && ( $file_size < 2120000))
{
$replace_str = array(" ", "&", "?","%");
$picture = str_replace($replace_str, '_', $file['name']);
$newfile = strtotime(date("d-m-y H:i:s"))."@".$picture;
$tmpName = $file['tmp_name'];
$Attach_Dir_thumb = '../../uploads/';
$Attach_Name = $Attach_Dir_thumb.$newfile;
if($newfile != '')
{
if(move_uploaded_file($file['tmp_name'], $Attach_Name))
{
$response['resp'] = "success";
$response['file'] = $newfile;
}
}
}
else
{
$response['resp'] = "No Image file found to upload.";
$response['file'] = "";
}
}
else
{
$response['resp'] = "Please check, file is attached.";
$response['file'] = "";
}
return $response;
}
function unlinkImage($filepath)
{
if(file_exists($filepath))
{
@unlink($filepath);
return "ok";
}
return "not";
}
}
?>