Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
sopham
/
todolist
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cba22584
authored
May 13, 2019
by
sopham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image location to database
parent
c6625a80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
function.js
upload.php
function.js
View file @
cba22584
...
...
@@ -15,23 +15,6 @@ function myFunction() {
document
.
getElementById
(
"myBar"
).
style
.
width
=
scrolled
+
"%"
;
}
//display image
/*
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#imagePreview').css('background-image', 'url('+e.target.result +')');
$('#imagePreview').hide();
$('#imagePreview').fadeIn(650);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imageUpload").change(function() {
readURL(this);
});
*/
//display input from database
$
(
document
).
ready
(
function
()
{
$
.
ajax
({
...
...
@@ -70,7 +53,7 @@ $(document).ready(function() {
var
files
=
$
(
'#imageUpload'
)[
0
].
files
[
0
];
fd
.
append
(
'file'
,
files
);
$
.
ajax
({
url
:
'
test
.php'
,
url
:
'
upload
.php'
,
type
:
'POST'
,
data
:
fd
,
contentType
:
false
,
...
...
upload.php
View file @
cba22584
<?php
session_start
();
include_once
'dbconnection.php'
;
if
(
is_uploaded_file
(
$_FILES
[
'file'
][
'tmp_name'
]))
{
$sourcePath
=
$_FILES
[
'file'
][
'tmp_name'
];
$targetPath
=
"upload/"
.
basename
(
$_SESSION
[
'name'
]
.
'.'
.
end
((
explode
(
"."
,
$_FILES
[
'file'
][
'name'
]))));
if
(
move_uploaded_file
(
$sourcePath
,
$targetPath
))
{
$_SESSION
[
'avatar'
]
=
$targetPath
;
$query
=
"UPDATE users SET image=? WHERE username=?"
;
$query
=
$link
->
prepare
(
$query
);
$query
->
bind_param
(
'ss'
,
$targetPath
,
$_SESSION
[
'name'
]);
$query
->
execute
();
$query
->
close
();
$link
->
close
();
//echo $_SESSION['name'];
echo
$targetPath
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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