-
Notifications
You must be signed in to change notification settings - Fork 0
/
resumeUpload.php
44 lines (31 loc) · 1.28 KB
/
resumeUpload.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
<?php
require_once("../DropboxUploader/DropboxUploader.php");
require_once("../DropboxUploader/credentials.php");
if ($_POST and $_FILES)
{
$resumeName = $_POST["resumeName"];
$resumeNetID = $_POST["resumeNetID"];
try
{
// raise exception on upload error
if ( ($_FILES['resume']['error'] !== UPLOAD_ERR_OK) || ($_FILES['resume']['name'] === "") )
throw new Exception("Resume did not upload properly. Please try again.");
// parse the extension from the file name
$ext = substr($_FILES['resume']['name'], strrpos($_FILES['resume']['name'], '.') + 1);
// raise exception if the file type is wrong
if ( ($ext != "pdf") && ($ext != "doc") && ($ext != "docx") )
throw new Exception("File type is not PDF or Microsoft Word document. Please try again.");
// get the file name based on student's information
$filename = $resumeName . " - " . $resumeNetID . " - Resume." . $ext;
$uploader = new DropboxUploader($dropbox_username, $dropbox_password);
// upload to the "resume" folder (if the folder doesn't exist, it will be created)
$uploader->upload($_FILES['resume']['tmp_name'], "SPAC 2015 Resumes", $filename);
echo "success";
}
catch(Exception $e)
{
// exception raised
echo $e->getMessage();
}
}
?>