Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
5c517cb4
Commit
5c517cb4
authored
Mar 26, 2020
by
Rosanny Sihombing
Browse files
fixing upload pictures
parent
3a4f8cad
Changes
1
Hide whitespace changes
Inline
Side-by-side
routes/routes-project.js
View file @
5c517cb4
...
...
@@ -164,12 +164,35 @@ module.exports = function (app) {
var
projectLogo
=
req
.
files
.
logo
var
projectPicture
=
req
.
files
.
src
// TEST PATH FOR DEVELOPMENT (LOCALHOST)
var
projectLogoPath
=
'
./folder-in-server-to-save-projektlogo/
'
+
req
.
body
.
pname
+
'
/
'
+
projectLogo
.
name
var
projectPicturePath
=
'
./folder-in-server-to-save-projektbild/
'
+
req
.
body
.
pname
+
'
/
'
+
projectPicture
.
name
// PATH FOR TEST/LIVE SERVER
// var projectLogoPath = to-be-defined
// var projectPicturePath = to-be-defined
var
projectLogoPath
,
projectPicturePath
if
(
projectLogo
)
{
// raise error if size limit is exceeded
if
(
projectLogo
.
size
===
pictSizeLimit
)
{
req
.
flash
(
'
error
'
,
'
Projektlogo exceeds 1 MB
'
);
res
.
redirect
(
'
/addprojectoverview
'
);
}
else
{
// TEST PATH FOR DEVELOPMENT (LOCALHOST)
projectLogoPath
=
'
./folder-in-server-to-save-projektlogo/
'
+
req
.
body
.
pname
+
'
/
'
+
projectLogo
.
name
// PATH FOR TEST/LIVE SERVER
// var projectLogoPath = to-be-defined
}
}
if
(
projectPicture
)
{
// raise error if size limit is exceeded
if
(
projectPicture
.
size
===
pictSizeLimit
)
{
req
.
flash
(
'
error
'
,
'
Projektbild exceeds 1 MB
'
);
res
.
redirect
(
'
/addprojectoverview
'
);
}
else
{
// TEST PATH FOR DEVELOPMENT (LOCALHOST)
projectPicturePath
=
'
./folder-in-server-to-save-projektbild/
'
+
req
.
body
.
pname
+
'
/
'
+
projectPicture
.
name
// PATH FOR TEST/LIVE SERVER
// var projectPicturePath = to-be-defined
}
}
var
projectTerm
=
req
.
body
.
termForm
+
"
-
"
+
req
.
body
.
termTo
var
projectOverviewData
=
{
...
...
@@ -197,34 +220,28 @@ module.exports = function (app) {
leader_email
:
req
.
body
.
leaderEmail
}
// raise error if limit is exceeded
if
(
projectLogo
&&
projectLogo
.
size
===
pictSizeLimit
)
{
req
.
flash
(
'
error
'
,
'
Projektlogo exceeds 1 MB
'
);
res
.
redirect
(
'
/addprojectoverview
'
);
// save pictures
if
(
projectLogo
)
{
projectLogo
.
mv
(
projectLogoPath
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
)
res
.
status
(
500
).
render
(
lang
+
'
/500
'
,
{
error
:
err
})
}
});
}
if
(
projectPicture
&&
projectPicture
.
size
===
pictSizeLimit
)
{
req
.
flash
(
'
error
'
,
'
Projektbild exceeds 1 MB
'
);
res
.
redirect
(
'
/addprojectoverview
'
);
if
(
projectPicture
)
{
projectPicture
.
mv
(
projectPicturePath
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
)
res
.
status
(
500
).
render
(
lang
+
'
/500
'
,
{
error
:
err
})
}
});
}
// save pictures
projectLogo
.
mv
(
'
./folder-in-server-to-save-projektlogo/
'
+
req
.
body
.
pname
+
'
/
'
+
projectLogo
.
name
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
)
res
.
status
(
500
).
render
(
lang
+
'
/500
'
,
{
error
:
err
})
}
});
projectPicture
.
mv
(
'
./folder-in-server-to-save-projektbild/
'
+
req
.
body
.
pname
+
'
/
'
+
projectPicture
.
name
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
)
res
.
status
(
500
).
render
(
lang
+
'
/500
'
,
{
error
:
err
})
}
});
/* RS: Temporary solution while Project DB is still in early phase.
When User DB and Project DB are integrated and quite stabil, this operation should be done in 1 transaction.
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment