Skip to content

Commit

Permalink
Fixing Document Repository path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jkat committed Apr 18, 2019
1 parent 623f382 commit 16351ba
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modules/document_repository/ajax/documentEditUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
$fileType = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

$uploadPath = "$base/modules/document_repository/user_uploads/$name/";
$fullPath = $uploadPath . $fileName;

// $category is a string representation of an ID, and so should be at
// least equal to zero.
Expand All @@ -66,22 +65,22 @@
);
}

// Check to see if $fullPath is writable. If not, throw an error. If it
// Check to see if $uploadPath is writable. If not, throw an error. If it
// doesn't exist, create an uploads folder for the logged-in user.
if (!is_writable($fullPath)) {
if (file_exists($fullPath)) {
if (!is_writable($uploadPath)) {
if (file_exists($uploadPath)) {
throw new LorisException(
"User uploads path in Document Repository is not writable."
);
}
mkdir($fullPath, 0770);
mkdir($uploadPath, 0770);
}

// Copy the uploaded file to the user's upload folder if possible.
// Insert a record of the file into the document_repository table
if (!move_uploaded_file(
$_FILES['file']['tmp_name'],
$fullPath . $fileName
$uploadPath . $fileName
)) {
throw new LorisException(
'ERROR: Could not upload file. Contact your administrator.'
Expand Down

0 comments on commit 16351ba

Please sign in to comment.