Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tetiana yaremko
/
web-app-group2
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
92467d34
authored
May 12, 2020
by
tetiana yaremko
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
upload file on live server
parent
b62a53e2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
10 deletions
app.yaml
application/config/config.php
application/controllers/Admin.php
application/models/Admin_model.php
application/views/admin/add_product.php
application/views/admin/update_item.php
application/views/templates/home_t.php
app.yaml
View file @
92467d34
...
...
@@ -9,3 +9,6 @@ handlers:
-
url
:
/.*
script
:
index.php
env_variables
:
GOOGLE_STORAGE_BUCKET
:
"
wbt-2-ty-272811.appspot.com"
application/config/config.php
View file @
92467d34
...
...
@@ -536,3 +536,15 @@ $config['rewrite_short_tags'] = FALSE;
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
$config
[
'proxy_ips'
]
=
''
;
$config
[
'upload_bucket'
]
=
'wbt-2-ty-272811.appspot.com'
;
$config
[
'upload_path'
]
=
ENVIRONMENT
==
'production'
?
'gs://'
.
$config
[
'upload_bucket'
]
:
'./uploads/'
;
// Prefix for building public URL to the uploaded file
$config
[
'upload_prefix'
]
=
ENVIRONMENT
==
'production'
?
'https://storage.cloud.google.com/'
.
$config
[
'upload_bucket'
]
.
'/'
:
$config
[
'base_url'
]
.
'uploads/'
;
application/controllers/Admin.php
View file @
92467d34
...
...
@@ -24,13 +24,16 @@ class Admin extends CI_Controller {
$this
->
form_validation
->
set_rules
(
"price"
,
"Price"
,
"required"
);
$this
->
form_validation
->
set_rules
(
"description"
,
"Description"
,
"required"
);
$config
[
'upload_path'
]
=
'./uploads/'
;
//$config['upload_path'] = './uploads/';
$config
[
'upload_path'
]
=
$this
->
config
->
item
(
'upload_path'
);
$config
[
'allowed_types'
]
=
'gif|jpg|png|jpeg'
;
$config
[
'max_size'
]
=
4048
;
$file_name
=
"image"
.
time
();
$config
[
'file_name'
]
=
$file_name
;
$config
[
'encrypt_name'
]
=
TRUE
;
$this
->
upload
->
initialize
(
$config
);
$field_name
=
"
imag
e"
;
$field_name
=
"
fil
e"
;
if
(
$this
->
form_validation
->
run
()
==
TRUE
)
{
if
(
!
$this
->
upload
->
do_upload
(
$field_name
))
{
...
...
@@ -41,6 +44,7 @@ class Admin extends CI_Controller {
}
else
{
$this
->
load
->
model
(
'Admin_model'
,
'admin'
);
$this
->
admin
->
add_product
();
$this
->
session
->
set_flashdata
(
"message"
,
"<div class=
\"
alert alert-success alert-dismissible fade show
\"
role=
\"
alert
\"
>
Product has been added to the database<button type=
\"
button
\"
class=
\"
close
\"
data-dismiss=
\"
alert
\"
aria-label=
\"
Close
\"
>
...
...
@@ -77,13 +81,21 @@ class Admin extends CI_Controller {
$this
->
form_validation
->
set_rules
(
"description"
,
"Description"
,
"required"
);
$this
->
form_validation
->
set_rules
(
"status"
,
"Status"
,
"required"
);
$config
[
'upload_path'
]
=
'./uploads/'
;
// $config['upload_path'] = './uploads/';
// $config['allowed_types'] = 'gif|jpg|png|jpeg';
// $config['max_size'] = 2048;
// $file_name="image".time();
// $config['file_name']=$file_name;
// $this->upload->initialize($config);
// $field_name = "file";
$config
[
'upload_path'
]
=
$this
->
config
->
item
(
'upload_path'
);
$config
[
'allowed_types'
]
=
'gif|jpg|png|jpeg'
;
$config
[
'max_size'
]
=
2
048
;
$config
[
'max_size'
]
=
4
048
;
$file_name
=
"image"
.
time
();
$config
[
'file_name'
]
=
$file_name
;
$config
[
'encrypt_name'
]
=
TRUE
;
$this
->
upload
->
initialize
(
$config
);
$field_name
=
"
imag
e"
;
$field_name
=
"
fil
e"
;
if
(
$this
->
form_validation
->
run
()
==
TRUE
)
{
if
(
!
$this
->
upload
->
do_upload
(
$field_name
))
{
...
...
application/models/Admin_model.php
View file @
92467d34
...
...
@@ -25,7 +25,8 @@ class Admin_model extends CI_Model
$query
=
$this
->
db
->
get
();
$status_id
=
$query
->
row
();
$image
=
$this
->
upload
->
data
();
//$image =$this->upload->data();
$image
=
$this
->
config
->
item
(
'upload_prefix'
)
.
$this
->
upload
->
data
(
'file_name'
);
//insert data from add_product input
$data
=
array
(
...
...
@@ -35,7 +36,7 @@ class Admin_model extends CI_Model
'q_ty'
=>
$this
->
input
->
post
(
'quantity'
),
'price'
=>
$this
->
input
->
post
(
'price'
),
'description'
=>
$this
->
input
->
post
(
'description'
),
'image'
=>
$image
[
'file_name'
]
,
'image'
=>
$image
,
'feature'
=>
$this
->
input
>
post
(
'feature'
),
'status_id'
=>
(
int
)
$status_id
->
id_status
);
...
...
application/views/admin/add_product.php
View file @
92467d34
...
...
@@ -117,11 +117,11 @@
</tr>
<tr>
<td>
<?php
$error
=
form_error
(
"
imag
e"
,
"<small class='text-danger'>"
,
'</small>'
);
?>
<?php
$error
=
form_error
(
"
fil
e"
,
"<small class='text-danger'>"
,
'</small>'
);
?>
<label
for=
"image"
>
Image
</label>
</td>
<td>
<input
name=
"
imag
e"
type=
"file"
class=
"form-control-file"
id=
"image"
aria-describedby=
"fileHelp"
>
<input
name=
"
fil
e"
type=
"file"
class=
"form-control-file"
id=
"image"
aria-describedby=
"fileHelp"
>
<div>
<?php
echo
$error
;
?>
</div>
</td>
</tr>
...
...
application/views/admin/update_item.php
View file @
92467d34
...
...
@@ -118,7 +118,7 @@
<label
for=
"image"
>
Image
</label>
</td>
<td>
<input
name=
"
imag
e"
type=
"file"
class=
"form-control-file"
id=
"image"
aria-describedby=
"fileHelp"
value=
"
<?php
set_value
(
base_url
(
"uploads/"
.
$data
->
image
)
)
?>
"
>
<input
name=
"
fil
e"
type=
"file"
class=
"form-control-file"
id=
"image"
aria-describedby=
"fileHelp"
value=
"
<?php
set_value
(
base_url
(
"uploads/"
.
$data
->
image
)
)
?>
"
>
</td>
</tr>
...
...
application/views/templates/home_t.php
View file @
92467d34
...
...
@@ -17,6 +17,7 @@
<body>
<div
class=
"head-offer"
>
<div
class=
"offer-list"
>
<ul
class=
"navigation offer"
>
...
...
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