Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | // A list of permitted file extensions |
---|
4 | $allowed = array('png', 'jpg', 'gif','zip'); |
---|
5 | |
---|
6 | if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){ |
---|
7 | |
---|
8 | $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION); |
---|
9 | |
---|
10 | if(!in_array(strtolower($extension), $allowed)){ |
---|
11 | echo '{"status":"error"}'; |
---|
12 | exit; |
---|
13 | } |
---|
14 | |
---|
15 | if(move_uploaded_file($_FILES['upl']['tmp_name'], 'uploads/'.$_FILES['upl']['name'])){ |
---|
16 | echo '{"status":"success"}'; |
---|
17 | exit; |
---|
18 | } |
---|
19 | } |
---|
20 | |
---|
21 | echo '{"status":"error"}'; |
---|
22 | exit; |
---|
Note: See
TracBrowser
for help on using the repository browser.