Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이수빈
/
Find_your_own_personal_color
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
조수연
2020-11-23 13:42:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d994a6b0b6482d533719a4bb9c37a6fe741985c0
d994a6b0
1 parent
8c7d7e71
image upload implement
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
205 additions
and
0 deletions
front/app.js
front/css.css
front/main.html
front/app.js
0 → 100644
View file @
d994a6b
function
readURL
(
input
)
{
if
(
input
.
files
&&
input
.
files
[
0
])
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
$
(
'.image-upload-wrap'
).
hide
();
$
(
'.file-upload-image'
).
attr
(
'src'
,
e
.
target
.
result
);
$
(
'.file-upload-content'
).
show
();
$
(
'.image-title'
).
html
(
input
.
files
[
0
].
name
);
};
reader
.
readAsDataURL
(
input
.
files
[
0
]);
}
else
{
removeUpload
();
}
}
function
removeUpload
()
{
$
(
'.file-upload-input'
).
replaceWith
(
$
(
'.file-upload-input'
).
clone
());
$
(
'.file-upload-content'
).
hide
();
$
(
'.image-upload-wrap'
).
show
();
}
$
(
'.image-upload-wrap'
).
bind
(
'dragover'
,
function
()
{
$
(
'.image-upload-wrap'
).
addClass
(
'image-dropping'
);
});
$
(
'.image-upload-wrap'
).
bind
(
'dragleave'
,
function
()
{
$
(
'.image-upload-wrap'
).
removeClass
(
'image-dropping'
);
});
front/css.css
0 → 100644
View file @
d994a6b
body
{
font-family
:
sans-serif
;
background-color
:
#eeeeee
;
}
.file-upload
{
background-color
:
#ffffff
;
width
:
600px
;
margin
:
0
auto
;
padding
:
20px
;
}
.file-upload-btn
{
width
:
100%
;
margin
:
0
;
color
:
#fff
;
background
:
#008b8b
;
border
:
none
;
padding
:
10px
;
border-radius
:
4px
;
border-bottom
:
4px
solid
#000000
;
transition
:
all
.2s
ease
;
outline
:
none
;
text-transform
:
uppercase
;
font-weight
:
700
;
}
.file-upload-btn
:hover
{
background
:
#1AA059
;
color
:
#ffffff
;
transition
:
all
.2s
ease
;
cursor
:
pointer
;
}
.file-upload-btn
:active
{
border
:
0
;
transition
:
all
.2s
ease
;
}
.file-upload-content
{
display
:
none
;
text-align
:
center
;
}
.file-upload-input
{
position
:
absolute
;
margin
:
0
;
padding
:
0
;
width
:
100%
;
height
:
100%
;
outline
:
none
;
opacity
:
0
;
cursor
:
pointer
;
}
.image-upload-wrap
{
margin-top
:
20px
;
border
:
4px
dashed
#696969
;
position
:
relative
;
}
.image-dropping
,
.image-upload-wrap
:hover
{
background-color
:
#dcdcdc
;
border
:
4px
dashed
#ffffff
;
}
.image-title-wrap
{
padding
:
0
15px
15px
15px
;
color
:
#222
;
}
.drag-text
{
text-align
:
center
;
}
.drag-text
h3
{
font-weight
:
100
;
text-transform
:
uppercase
;
color
:
#000000
;
padding
:
60px
0
;
}
.file-upload-image
{
max-height
:
200px
;
max-width
:
200px
;
margin
:
auto
;
padding
:
20px
;
}
.remove-image
{
width
:
200px
;
margin
:
0
;
color
:
#fff
;
background
:
#cd4535
;
border
:
none
;
padding
:
10px
;
border-radius
:
4px
;
border-bottom
:
4px
solid
#b02818
;
transition
:
all
.2s
ease
;
outline
:
none
;
text-transform
:
uppercase
;
font-weight
:
700
;
}
.remove-image
:hover
{
background
:
#c13b2a
;
color
:
#ffffff
;
transition
:
all
.2s
ease
;
cursor
:
pointer
;
}
.remove-image
:active
{
border
:
0
;
transition
:
all
.2s
ease
;
}
front/main.html
0 → 100644
View file @
d994a6b
<link
rel=
"stylesheet"
type=
"text/css"
href=
"css.css"
>
<script
class=
"jsbin"
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
></script>
<div
class=
"file-upload"
>
<button
class=
"file-upload-btn"
type=
"button"
onclick=
"$('.file-upload-input').trigger( 'click' )"
>
Add Image
</button>
<div
class=
"image-upload-wrap"
>
<input
class=
"file-upload-input"
type=
'file'
onchange=
"readURL(this);"
accept=
"image/*"
/>
<div
class=
"drag-text"
>
<h3>
UPLOAD
</h3>
</div>
</div>
<div
class=
"file-upload-content"
>
<img
class=
"file-upload-image"
src=
"#"
alt=
"your image"
/>
<div
class=
"image-title-wrap"
>
<button
type=
"button"
onclick=
"removeUpload()"
class=
"remove-image"
>
Remove
<span
class=
"image-title"
>
Uploaded Image
</span></button>
</div>
</div>
</div>
<h5><center>
Copyright (c) 2020 by Aaron Vanston (https://codepen.io/aaronvanston/pen/yNYOXR)
</center></h5>
<script>
function
readURL
(
input
)
{
if
(
input
.
files
&&
input
.
files
[
0
])
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
$
(
'.image-upload-wrap'
).
hide
();
$
(
'.file-upload-image'
).
attr
(
'src'
,
e
.
target
.
result
);
$
(
'.file-upload-content'
).
show
();
$
(
'.image-title'
).
html
(
input
.
files
[
0
].
name
);
};
reader
.
readAsDataURL
(
input
.
files
[
0
]);
}
else
{
removeUpload
();
}
}
function
removeUpload
()
{
$
(
'.file-upload-input'
).
replaceWith
(
$
(
'.file-upload-input'
).
clone
());
$
(
'.file-upload-content'
).
hide
();
$
(
'.image-upload-wrap'
).
show
();
}
$
(
'.image-upload-wrap'
).
bind
(
'dragover'
,
function
()
{
$
(
'.image-upload-wrap'
).
addClass
(
'image-dropping'
);
});
$
(
'.image-upload-wrap'
).
bind
(
'dragleave'
,
function
()
{
$
(
'.image-upload-wrap'
).
removeClass
(
'image-dropping'
);
});
</script>
\ No newline at end of file
Please
register
or
login
to post a comment