-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
51 lines (42 loc) · 1.55 KB
/
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
<?php
require('driveup.php');
require('logger.php');
/* FOR MULTIPLE MEDIA FILES
foreach(array('video', 'audio') as $type) {
if (isset($_FILES["${type}-blob"])) {
echo 'uploads/';
$fileName = $_POST["${type}-filename"];
$uploadDirectory = 'uploads/'.$fileName;
if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) {
echo(" problem moving uploaded file");
}
echo($fileName);
}
}
*/
$currentDir = getcwd();
$uploadDirectory = "/uploads/";
$log = new Log();
$fileName = $_FILES['media']['name'];
$fileSize = $_FILES['media']['size'];
$fileTmpName = $_FILES['media']['tmp_name'];
$fileType = $_FILES['media']['type'];
$uploadPath = $currentDir . $uploadDirectory . $_POST['u'] .'_' . uniqid() .'.webm';
$didUpload = move_uploaded_file($fileTmpName, $uploadPath);
if ($didUpload) {
$log->write('Uploaded '.$uploadPath.' to server. Attempting to upload to Drive');
$result = uploadToDrive($uploadPath);
if($result['name'] == basename($uploadPath)) {
$log->write('Uploaded '.$uploadPath.' to Drive');
unlink($uploadPath);
echo 'Success';
}
else {
$log->write('Error saving '.$uploadPath.' to Drive');
echo 'Error saving file to server';
}
} else {
$log->write('Error uploading '.$uploadPath.' to server');
echo 'Error uploading file';
}
?>