Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박민정
/
We-Shop
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박민정
2021-06-09 23:20:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5d9bd089c1e52725824dcec9257ed06792f5bf1f
5d9bd089
1 parent
f60c37ed
[fix] Fix 504 error
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
We-Shop/client/src/components/utils/ImageUpload.js
We-Shop/server/index.js
We-Shop/server/routes/product.js
We-Shop/client/src/components/utils/ImageUpload.js
View file @
5d9bd08
...
...
@@ -5,7 +5,7 @@ import axios from 'axios';
function
ImageUpload
()
{
const
imageDropEvent
=
(
files
)
=>
{
let
imageData
=
new
image
Data
();
let
imageData
=
new
Form
Data
();
const
config
=
{
header
:
{
'content-type'
:
'multipart/image-data'
}
...
...
We-Shop/server/index.js
View file @
5d9bd08
...
...
@@ -30,7 +30,7 @@ app.use(cors())
app
.
use
(
'/api/users'
,
require
(
'./routes/users'
));
app
.
use
(
'/api/image'
,
require
(
'./routes/product
Image
'
));
app
.
use
(
'/api/image'
,
require
(
'./routes/product'
));
// 업로드 하려고
app
.
use
(
'/uploads'
,
express
.
static
(
'uploads'
));
...
...
We-Shop/server/routes/product.js
0 → 100644
View file @
5d9bd08
const
express
=
require
(
'express'
);
const
{
User
}
=
require
(
"../models/User"
);
const
{
auth
}
=
require
(
"../middleware/auth"
);
const
router
=
express
.
Router
();
const
multer
=
require
(
'multer'
);
var
storage
=
multer
.
diskStorage
({
destination
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
'uploads/'
)
// 어느 폴더에 저장할건지
},
filename
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
Date
.
now
()
+
'_'
+
file
.
originalname
)
// 이미지 이름
}
})
var
upload
=
multer
({
storage
:
storage
}).
single
(
"file"
);
router
.
post
(
'/image'
,
(
req
,
res
)
=>
{
// 클라이언트로부터 받은 이미지 저장
upload
(
req
,
res
,
(
err
)
=>
{
if
(
err
)
return
req
.
json
({
success
:
false
,
err
})
return
res
.
json
({
success
:
true
,
filePath
:
res
.
req
.
file
.
path
,
fileName
:
res
.
req
.
file
.
filename
})
}
)
})
module
.
exports
=
router
;
Please
register
or
login
to post a comment