-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
51 lines (37 loc) · 1.11 KB
/
upload.php
File metadata and controls
51 lines (37 loc) · 1.11 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
<?php
error_reporting(E_ALL);
// https://makitweb.com/how-to-upload-file-with-javascript-and-php/
if(isset($_FILES['file']['name'])){
// file name
$filename = $_FILES['file']['name'];
$data = $_FILES['file']['tmp_name'];
// Location
$location = 'dump/'.$filename;
//$dir = "../wp-content/uploads/wp_dndcf7_uploads/wpcf7-files/";
//$location = $dir.$filename;
// file extension
$file_extension = pathinfo($location, PATHINFO_EXTENSION);
$file_extension = strtolower($file_extension);
if( $file_extension == "txt")
{
// Open the file to get existing content
$current = file_get_contents($data);
// Append a new person to the file
// Write the contents back to the file
file_put_contents($data, $current);
}
// Valid extensions
$valid_ext = array("txt","pdf","doc","docx","jpg","png","jpeg");
$response = 0;
if(in_array($file_extension, $valid_ext))
{
// Upload file
if(move_uploaded_file($data, $location))
{
$response = 1;
}
}
echo $response;
exit;
}
?>