-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileindb.php
More file actions
executable file
·82 lines (72 loc) · 3.46 KB
/
Copy pathfileindb.php
File metadata and controls
executable file
·82 lines (72 loc) · 3.46 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
<?php
session_start();
if (!isset($_SESSION['user']))
{
header("Location: login.php");
}
?>
<meta HTTP-EQUIV="REFRESH" content="0; url=files.php">
<?php
require "config.php";
//file table entries
$fileName = $_FILES['path']['name'];
$tmpName = $_FILES['path']['tmp_name'];
$fileSize = $_FILES['path']['size'];
$fileType = $_FILES['path']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$MAX_FILE_SIZE=$_POST['MAX_FILE_SIZE']; //This value has to be the same as in the HTML form file
$personid=$_POST['personid']; //This value has to be the same as in the HTML form file
$caseid=$_POST['caseid']; //This value has to be the same as in the HTML form file
$SetType=$_POST['action']; //This value has to be the same as in the HTML form file
$lite=$_POST['lite']; //This value has to be the same as in the HTML form file
$descr=$_POST['descr']; //This value has to be the same as in the HTML form file
$userid=$_SESSION['userid'];
$entryid=md5(uniqid()); // a random 32 digits code is generated
// check for an empty string and display a message.
if ($fileSize >= $MAX_FILE_SIZE)
{
echo "<p><a href='javascript:' onclick='history.go(-1); return false' style='text-decoration: none;'>Upload not permitted. File larger than 2Mb</a></p>";
exit;
}
if ($caseid != "")
{
if ($descr == "")
{
$descr = $fileName;
//insert to document
$sql1=mysql_query("INSERT INTO document (descr,createdate,content,userid,doctypeid,caseid,entryid,istemplate,isdeleted,filename,filetype,filesize) VALUES ('$descr',NOW(),'$content','$userid','$SetType','$caseid','$entryid','$lite',0,'$fileName','$fileType','$fileSize')") or die("INSERT cases Error: ".mysql_error()); /*contacts is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
}
else if ($descr != "")
{
//insert to document
$sql2=mysql_query("INSERT INTO document (descr,createdate,content,userid,doctypeid,caseid,entryid,istemplate,isdeleted,filename,filetype,filesize) VALUES ('$descr',NOW(),'$content','$userid','$SetType','$caserid','$entryid','$lite',0,'$fileName','$fileType','$fileSize')") or die("INSERT cases Error: ".mysql_error()); /*contacts is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
}
}
if ($caseid == "")
{
if ($descr == "")
{
$descr = $fileName;
//insert to document
$sql1=mysql_query("INSERT INTO document (descr,createdate,content,userid,doctypeid,personid,entryid,istemplate,isdeleted,filename,filetype,filesize) VALUES ('$descr',NOW(),'$content','$userid','$SetType','$personid','$entryid','$lite',0,'$fileName','$fileType','$fileSize')") or die("INSERT cases Error: ".mysql_error()); /*contacts is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
}
else if ($descr != "")
{
//insert to document
$sql2=mysql_query("INSERT INTO document (descr,createdate,content,userid,doctypeid,personid,entryid,istemplate,isdeleted,filename,filetype,filesize) VALUES ('$descr',NOW(),'$content','$userid','$SetType','$personid','$entryid','$lite',0,'$fileName','$fileType','$fileSize')") or die("INSERT cases Error: ".mysql_error()); /*contacts is the name of the MySQL table where the form data will be saved.
name and email are the respective table fields*/
}
}
echo "The form data was successfully added to your database.";
mysql_close();
?>