Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Bojan Borovcanin
/
WBT1920_team30
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
29a8f5d9
authored
May 11, 2020
by
Bojan Borovcanin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Controller changed to upload image files to database
parent
d1168d65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
test/controllers/Activity.php
test/controllers/Activity.php
View file @
29a8f5d9
...
...
@@ -58,7 +58,6 @@ class Activity extends CI_Controller{
$this
->
form_validation
->
set_rules
(
'title'
,
'Title'
,
'required|max_length[30]'
);
$this
->
form_validation
->
set_rules
(
'description'
,
'Description'
,
'required|max_length[300]'
);
$this
->
form_validation
->
set_rules
(
'datetime'
,
'DateTime'
,
'required'
);
$this
->
form_validation
->
set_rules
(
'inpImage'
,
'Image'
,
'required'
);
$this
->
form_validation
->
set_rules
(
'price'
,
'Price'
,
'required|max_length[30]'
);
$this
->
form_validation
->
set_rules
(
'full_name'
,
'Full name'
,
'required|max_length[30]'
);
$this
->
form_validation
->
set_rules
(
'phone_number'
,
'Phone number'
,
'required|max_length[30]'
);
...
...
@@ -75,12 +74,27 @@ class Activity extends CI_Controller{
$data
[
'title'
]
=
$this
->
input
->
post
(
'title'
);
$data
[
'description'
]
=
$this
->
input
->
post
(
'description'
);
$data
[
'datetime'
]
=
$this
->
input
->
post
(
'datetime'
);
$data
[
'image'
]
=
$this
->
input
->
post
(
'inpImage'
);
$data
[
'price'
]
=
$this
->
input
->
post
(
'price'
);
$data
[
'full_name'
]
=
$this
->
input
->
post
(
'full_name'
);
$data
[
'phone_number'
]
=
$this
->
input
->
post
(
'phone_number'
);
$data
[
'email'
]
=
$this
->
input
->
post
(
'email'
);
$content
;
$tmpname
=
$_FILES
[
'inpImage'
][
'tmp_name'
];
//The temporary filename of the file in which the uploaded file was stored on the server.
$filesize
=
$_FILES
[
'inpImage'
][
'size'
];
$filetype
=
$_FILES
[
'inpImage'
][
'type'
];
$allowedtypes
=
array
(
"image/jpeg"
,
"image/jpg"
,
"image/png"
,
"image/gif"
);
if
(
$filesize
>=
0
){
if
(
in_array
(
$filetype
,
$allowedtypes
))
{
$fp
=
fopen
(
$tmpname
,
'r'
);
$content
=
fread
(
$fp
,
filesize
(
$tmpname
));
$data
[
'image'
]
=
$content
;
//it adds blackslashes after each quote(double or single)
fclose
(
$fp
);
}
}
$this
->
Activity_model
->
addNewActivity
(
$data
);
$array
[
'activities'
]
=
$this
->
Activity_model
->
getAllActivities
();
...
...
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