-
Notifications
You must be signed in to change notification settings - Fork 2
/
sc_upload.php
113 lines (86 loc) · 2.74 KB
/
sc_upload.php
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" />
<script type="text/javascript" src="script/jquery-latest.js"></script>
<?php
session_start();
function random_generate()
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < 10; $i++)
{
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
require_once 'scribd.php';
//Connecting to Database//
//$db=mysqli_connect('localhost','root','','compiler') or die('Error in connecting');
//print_r($_FILES);
echo"<br>";
$fileName=$_FILES['doc']['name'];
$file_info=pathinfo($fileName);
$fileExt=$file_info['extension'];
$fileLoc=$_FILES['doc']['tmp_name'];
$fileSize=$_FILES['doc']['size'];
/*Upload it to the Scribd
What is needed ? 1) Scribd API KEy, Scribd Secret Key
2) Construct a Scribd Object with that (All the methods are given in "Scribd.php"
3) Use the scribd Object to call the upload Function
4) The function Will return "doc_id" and "access_key" for that doc
5) Then use "script" to display it
*/
//Creating Scribd Object//
$api="7fs5j960mfy4seft72lbj";
$secret="7fs5j960mfy4seft72lbj";
$scribd=new Scribd($api,$secret);
//Object Created
//print_r($scribd);
$doc_type=$fileExt;
$access=null;
$rev_id=null;
$data=$scribd->upload($fileLoc,$doc_type,$access,$rev_id);
if($data)
{
echo "<center>File Uploaded Successfully</center>";
// $result=$scribd->getDownloadUrl(133452555,$doc_type);
// $result=file_get_contents($result['download_link']);
$docid=$data['doc_id'];
$akey=$data['access_key'];
$type="txt";
sleep(60);
$content=$scribd->getDownloadUrl($docid,$type);
$content=$content['download_link'];
$content=file_get_contents($content);
echo $content;
$x=random_generate();
include('connect.php');
$query="INSERT INTO `resume`.`resume`(`uid`) values('$x');";
$res=mysqli_query($dbc,$query);
$file=fopen("resumes/".$x.".txt","w+");
fwrite($file,$content);
fclose($file);
$_SESSION['upload']=1;
$_SESSION['uid']=$x;
header('location:employee.php');
//$query="INSERT INTO `compiler`.`document` VALUES('$fileName','$docid','$akey');";
//$result=mysqli_query($db,$query) or die('Error in executing query');
}
//Data Array Contains Both the "doc_id" and "access_key"
?>
<!--<input type="button" value="Check with Other Document" id='check' />
<div id='load'>
</div>
<script type="text/javascript">
var fileid='<?php //echo $docid; ?>';
var filetype='<?php //echo $fileExt; ?>';
$(document).ready(function()
{
alert(fileid);
$('#check').click(function()
{
$('#load').text('');
$('#load').load('doc.php',{fileid:fileid,filetype:filetype});
alert("Fetching Text");
});
});
</script>-->