I'm currently building a portfolio site for a client, and I'm having trouble with one small area. I want to be able to upload multiple images (varying number) inline for each portfolio item, and I can't see an obvious way to do it.
My view.php:
<?php echo form_open_multipart('uploadfile/upload');?>
<fieldset>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<label for="filename[]" class="control-label">Select File to Upload</label>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<input type="file" name="filename" size="20" />
<span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<input type="submit" value="Upload File" class="btn btn-primary"/>
</div>
</div>
</div>
</fieldset>
<?php echo form_close(); ?>
<?php if (isset($success_msg)) { echo $success_msg; } ?>
</div>
my controller
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
ini_set("display_errors",1);
class Update_profile extends CI_Controller {
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->is_login();
$this->load->helper(array('form', 'url'));
$this->load->model('Edit_profile');
}
public function index() {
// $this->load->view('header2');
$this->load->view('edit_profile');
}// index function ends
public function is_login() {
$is_login=$this->session->userdata('is_login');
if(!isset($is_login) || $is_login !=true)
{
//don't echo the message from controller
echo "you don't have permission to access this page <a href=../Homecontroller/index/>Login</a>";
die();
}
} //is_login function ends
// function to upload images
function upload()
{
$name_array = array();
$count = count($_FILES['filename']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<=$count-1; $s++) {
$_FILES['filename']['name']=$value['name'][$s];
$_FILES['filename']['type'] = $value['type'][$s];
$_FILES['filename']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['filename']['error'] = $value['error'][$s];
$_FILES['filename']['size'] = $value['size'][$s];
//set preferences
$config['remove_spaces']=TRUE;
// $config['encrypt_name'] = TRUE; // for encrypting the name
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'jpg|png|gif';
$config['max_size'] = '10248';
//load upload class library
$this->load->library('upload', $config);
if (!$this->upload->do_upload('filename'))
{
// case - failure
$upload_error = array('error' => $this->upload->display_errors());
$this->load->view('edit_profile', $upload_error);
}
else
{
// case - success
$upload_data = $this->upload->data();
$name_array[] = $data['file_name'];
$data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' . $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
$this->load->view('edit_profile', $data);
}
}
}
function edit_profile() {
//echo "some success";
} //function edit profile ends
}
code above not working
This is what I've used for the last year when I've wanted/needed multiple image uploads in codeigniter:
https://github.com/stvnthomas/CodeIgniter-Multi-Upload
Related
Codeigniter When i use enctype="multipart/form-data" in signup form photo not save in database but photo going to uploads folder. Then When i remove enctype="multipart/form-data" photo save in database but photo not coming uploads folder. If this is problem for the code, please do the full code. Because I'm not a good developer.
View
<form method="post" action="family_join" enctype="multipart/form-data" id="wizard">
<h4 class="text-center mb-4 mt-4">Upload Photo</h4>
<div class="form-group mt-3 mb-4">
<div class="dropzone-wrapper">
<div class="dropzone-desc">
<i class="glyphicon glyphicon-download-alt"></i>
<p>Choose an image file or drag it here.</p>
</div>
<input type="file" name="photo" class="dropzone">
</div>
</div>
<h4 class="text-center mb-4">Please enter the zipcode</h4>
<div class="default-form contact-form">
<div class="form-group">
<input type="text" name="zipcode" placeholder="Enter Zip Code" required>
</div>
</div>
</form>
Controller
< ? php
defined('BASEPATH') OR exit('No direct script access allowed');
Class Family_Join extends CI_Controller {
public
function __construct() {
parent::__construct();
$this->load-> helper(array('form', 'url'));
}
public
function index() {
$this->form_validation-> set_rules('zipcode', 'Zipcode', 'required|min_length[4]');
if ($this->form_validation->run()) {
$zipcode=$this->input->post('zipcode');
$photo=$this->input->post('photo');
$status = 1;
$this->load->model('Family_Join_Model');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$this->upload->do_upload('photo');
$this-> Family_Join_Model->insert($zipcode, $photo, $status);
} else {
$this->load->view('user/family_join', array('error' => ' '));
}
}
}
Model
< ? php
defined('BASEPATH') OR exit('No direct script access allowed');
Class Family_Join_Model extends CI_Model {
public
function insert($zipcode, $photo, $status) {
$data = array(
'zipcode' => $zipcode,
'photo' => $photo,
'isActive' => $status
);
$sql_query=$this->db->insert('tblfm', $data);
if ($sql_query) {
$this->session->set_flashdata('success', 'Registration successfull');
redirect('user/family_join');
} else {
$this->session->set_flashdata('error', 'Somthing went worng. Error!!');
redirect('user/family_join');
}
}
}
That happens because when you set enctype to multipart/form-data your input send to server as a binary file and a binary file can not be inserted in database.
For inserting file name into your database follow steps below.
Keep enctype=multipart/form-data (So your file will be uploaded to server)
replace this line :
$this->Family_Join_Model->insert($zipcode, $photo, $status);
with these:
$upload_data = $this->upload->data();
$this->Family_Join_Model->insert($zipcode, $upload_data['file_name'], $status);
Upload file first and get the file name from uploaded file data.
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ($this->upload->do_upload('photo')) {
$file_details = $this->upload->data();
$photo = $file_details['file_name'];
} else {
$file_upload_msg = $this->upload->display_errors('<p>', '</p>');
}
$this->upload->do_upload('photo');
$upload_data = $this->upload->data();
$this->Family_Join_Model->insert($zipcode, $upload_data, $status);
**Model**
public
function insert($zipcode, $upload_data, $status) {
$data = array(
'zipcode' => $zipcode,
'photo' => $upload_data['file_name'],
'isActive' => $status
);
$sql_query=$this->db->insert('tblfm', $data);
if ($sql_query) {
$this->session->set_flashdata('success', 'Registration successfull');
redirect('user/family_join');
} else {
$this->session->set_flashdata('error', 'Somthing went worng. Error!!');
redirect('user/family_join');
}
}
so i try to make some upload form which will upload some image. but when the image has chosen then the button submit has clicked the result say "You did not select a file to upload."
im using php, with codeigniter framework
The view
<form class="text-left" enctype="multipart/form-data" method="post" action="<?= base_url('aduan/add'); ?>">
<div class="form-group">
<label>Upload Foto Bukti Aduan</label>
<div class="form-group">
<label>Bukti Aduan 1</label>
<input class="form-control-file" type="file" id="bukti1" name="bukti_aduan1" />
<?= form_error('bukti_aduan1', '<p class="text-danger font-weight-bold pl-2">', '</p>'); ?>
</div>
<div class="form-group">
<label>Bukti Aduan Pelapor di Lokasi</label>
<input class="form-control-file" type="file" id="bukti2" name="bukti_aduan2" />
<?= form_error('bukti_aduan2', '<p class="text-danger font-weight-bold pl-2">', '</p>'); ?>
</div>
</div>
which the view will run the controller "aduan" for input function
Controller file:
$aduan = $this->aduan_model;
$validation = $this->form_validation;
$validation->set_rules($aduan->rules());
if ($validation->run()) {
$aduan->tambah();
$this->session->set_flashdata('success', 'Berhasil disimpan');
$data['title'] = 'Buat Aduan Kasus Lingkungan';
$this->load->view('home/home_header', $data);
$this->load->view('home/aduansukses');
$this->load->view('home/home_footer');
} else {
$data['aduan'] = $this->aduan_model->getAll();
$data['title'] = 'Buat Aduan Kasus Lingkungan';
$this->load->view('home/home_header', $data);
$this->load->view('home/buataduan');
$this->load->view('home/home_footer');
}
then the controller will load a model which is "aduan_model"
Model file :
public function tambah()
{
$post = $this->input->post();
$this->nik_pelapor = $post["nik_pelapor"];
$this->nama_pelapor = $post["nama_pelapor"];
$this->email_pelapor = $post["email_pelapor"];
$this->telp_pelapor = $post["telp_pelapor"];
$this->alamat_pelapor = $post["alamat_pelapor"];
$this->aduan = $post["aduan"];
$this->bukti_aduan1 = $this->_uploadImage();
$this->bukti_aduan2 = $this->_uploadImage2();
$this->status_aduan = 'Dalam proses';
$this->tgl_aduan = time();
$this->db->insert($this->_table, $this);
}
private function _uploadImage()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
// $config['max_width'] = 1024;
// $config['max_height'] = 768;
$this->load->library('upload', $config);
if ($this->upload->do_upload('bukti_aduan1')) {
return $this->upload->data();
}
return "default.jpg";
}
private function _uploadImage2()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
// $config['max_width'] = 1024;
// $config['max_height'] = 768;
$this->load->library('upload', $config);
if ($this->upload->do_upload('bukti_aduan2')) {
return $this->upload->data();
}
return "default.jpg";
}
i expect the output of image can be stored in file upload and inserted in database but it doesnt select any file
please help :)
try my code
replace if condition in controller to upload
if(
(!$this->upload->do_upload('bukti_aduan2')) &&
(! $this->upload->do_upload('bukti_aduan1'))
)
{
echo "failed";
}
else
{
echo "success";
}
I'm new to codeigniter, and I'm trying to make a form that updates a profile. It has worked before but now it doesn't anymore.
I changed something in the view and it stopped working. I changed it back to where it was but it doesn't work anymore. I spend half a day trying to make it work again but I failed.
Maybe I don't see what you guys can see. At least I hope so.
this is my view:
<?php echo form_open_multipart('Gids/do_upload');?>
<img width="200px" src="<?php echo base_url()."uploads/".$profile[0]['image']; ?>" alt=""/>
<label for="">Uploade new picture:</label><input type="file" name="userfile" size="20" value="128.jpg" >
<input style="display: none" id="image" name="image" type="text" value="<?php echo "profile_picture".$_SESSION['id'].".jpg"; ?>"/>
<label for="naam">Naam:</label><input id="naam" name="naam" type="text" value="<?php echo $profile[0]['naam']; ?>"/>
<label for="voornaam">Voornaam:</label><input id="voornaam" name="voornaam" type="text" value="<?php echo $profile[0]['voornaam']; ?>"/>
<label for="email">Gebruikersnaam:</label><input id="gebruikersnaam" name="gebruikersnaam" type="text" value="<?php echo $profile[0]['gebruikersnaam']; ?>"/>
<label for="email">Email:</label><input id="email" name="email" type="text" value="<?php echo $profile[0]['email']; ?>"/>
<label for="opleiding">Opleiding:</label><input id="opleiding" name="opleiding" type="text" value="<?php echo $profile[0]['opleiding']; ?>"/>
<label for="school">School:</label><input id="school" name="school" type="text" value="<?php echo $profile[0]['school']; ?>"/>
<label for="wachtwoord">Wachtwoord:</label><input id="wachtwoord" name="wachtwoord" type="text" />
<label for="typeAgain">Type Opnieuw:</label><input id="typeAgain" type="text" />
<label for="over">Over mezelf:</label><textarea name="over" id="over" cols="30" rows="10"><?php echo $profile[0]['over']?></textarea>
<input type='text' style="display: none" name='student_id' value="<?php echo $profile[0]['student_id']?>"/>
<button class="btn btn-default" id="changeprofile" type="submit">Wijzigingen opslaan</button>
</form>
As you can see there is also a image upload
this is my controller:
function do_upload()
{
$this->load->model("Gids_model",'',true);
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['file_name'] = 'profile_picture'.$_SESSION['id'].'.jpg';
$config['overwrite'] = 'TRUE';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error_upload = array('error' => $this->upload->display_errors());
redirect('Gids/datum', $error_upload);
}
else
{
$this->Gids_model->update_profile($this->input->post('student_id'), $this->input->post('voornaam'), $this->input->post('naam'), $this->input->post('email'), $this->input->post('wachtwoord'), $this->input->post('opleiding'), $this->input->post('school'), $this->input->post('over'), $this->input->post('image'), $this->input->post('gebruikersnaam'));
//$e = $this->input->post('student_id');
$data_upload = array('upload_data' => $this->upload->data());
redirect('Gids/datum', $data_upload);
}
}
And this is my model:
public function update_profile($id, $voornaam, $naam, $email, $wachtwoord, $opleiding, $school, $over, $image, $gebruikersnaam){
$data = array(
'student_id' => $id,
'voornaam' => $voornaam,
'naam' => $naam,
'email' => $email,
'wachtwoord' => $wachtwoord,
'opleiding' => $opleiding,
'school' => $school,
'over' => $over,
'image' => $image,
'gebruikersnaam' => $gebruikersnaam
);
$this->db->where('student_id', $id);
$this->db->update('tbl_student', $data);
}
Could you please help me out.
Also I don't know what the form_open_multipart('Gids/do_upload') is for, I got it from a tutorial to upload images with codeigniter.
Here is what i tried
public function do_upload() {
$this->load->model("Gids_model",'',true);
// load library or you can do it with autoloading
// feature of CI
$this->load->library('upload');
// make sure that the folder uploads is created
// at the root directory of the project
$config = array(
'upload_path' => './uploads',
'allowed_types' => 'jpg|jpeg|JPG|JPEG|png',
'max_size' => '1000',
'file_name' => 'profile_picture.jpg',
'overwrite' => true
);
// use initialize instead
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userfile'))
{
$error_upload = array('error' => $this->upload->display_errors());
// you can check the errors here by using var_dump();
// just uncomment the the line below
// var_dump($this->upload->display_errors());die();
redirect('Gids/datum', $error_upload);
}
else
{
$this->Gids_model->update_profile($this->input->post('student_id'), $this->input->post('voornaam'), $this->input->post('naam'), $this->input->post('email'), $this->input->post('wachtwoord'), $this->input->post('opleiding'), $this->input->post('school'), $this->input->post('over'), $this->input->post('image'), $this->input->post('gebruikersnaam'));
//$e = $this->input->post('student_id');
$data_upload = array('upload_data' => $this->upload->data());
redirect('Gids/datum', $data_upload);
}
}
I tried this and hope it helps:
Controller :
public function upload_profile() {
$input = $this->input->post();
$config['upload_path'] = './uploads/profile_pics/'; //path were I save the uploaded profile pics
$config['allowed_types'] = 'gif|jpg|png'; // allowed types that is mention
//size of the picture by default
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['overwrite'] = true;
$this->load->library('upload', $config);
// display error if the picture is not on the config (sample bmp)
if ( ! $this->upload->do_upload())
{
$error = $this->upload->display_errors(); // display the errors
$data['upload_error'] = $error;
if($this->session->userdata('account_id') != null) { // if there is an account
$this->load->model('profile'); //model
$this->load->model('account'); //model
$data['user'] = $this->profile->get_profile($this->session->userdata('account_id')); //get_profile is a function in model
$data['account'] = $this->account->get_account($this->session->userdata('account_id')); //get_account is a function in model
$data['view'] = 'users/settings';
$data['title'] = "User's Settings";
$data['error'] = $error;
$this->load->view('masterpage', $data);
} else {
redirect(base_url('index.php/qablog/login'));
}
}
else
{
//if no error
$data = $this->upload->data();
$updateProfile = array(
'profile_pic' => $data['file_name']
);
$this->load->model('profile');
$this->profile->update_profile($this->session->userdata('account_id'), $updateProfile); // update the profile of the user
redirect(base_url('index.php/users/profile'));
}
}
Model get_profile():
public function get_profile($profile_id)
{
$this->db->select()->from('profile_tbl')->where('profile_id', $profile_id);
$query = $this->db->get();
return $query->first_row('array');
}
Model update_profile():
public function update_profile($profile_id, $data)
{
$this->db->where('profile_id', $profile_id);
$this->db->update('profile_tbl', $data);
return $this->db->affected_rows();
}
Model get_account():
public function get_account($account_id)
{
$this->db->select()->from('account_tbl');
$this->db->where('account_id', $account_id);
$query = $this->db->get();
return $query->result_array();
}
View :
//if there is an error
<?php
if ($error == 3) {?>
<div class="alert alert-success">
×
<strong>Success!</strong> Account or Profile Changed Successfully.
</div>
<?php } else if ($error == 1) { ?>
<div class="alert alert-warning">
×
<strong>Warning!</strong>Password Entered is Incorrect!.
</div>
<?php }else if ($error == 2) { ?>
<div class="alert alert-warning">
×
<strong>Warning!</strong>New Password and Confirm Password!.
</div>
<?php }?>
// default.png if haven't uploaded profile picture
<?php $profilePic = "default.png"; ?>
// if already uploaded profile picture it will display
<?php if($user['profile_pic'] != null) { ?>
<?php $profilePic = $user['profile_pic']; ?>
<?php } ?>
// if there is an error in uploading
<?php if(isset($upload_error)) { ?>
<div class="col-lg-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
Uploading profile image could not be completed. <?php print_r($upload_error); ?>
</div>
</div>
<?php } ?>
<div class="col-lg-12">
//display the profile picture
<img src="<?php echo base_url('uploads/profile_pics/'.$profilePic); ?>" width="100" />
// call the controller upload_profile
<?php echo form_open_multipart(base_url('index.php/users/upload_profile'));?>
<input type="file" name="userfile" id="userfile" size="20" style="display:none;" />
<label for="userfile" class="btn btn-info btn-sm">Choose Image</label>
<input type="submit" class="btn btn-xs" value="edit profile" />
</form>
<h3 class="text-info"><?php echo $user['fname'].' '.$user['lname']; ?></h3>
</div>
Just follow this, and if you have problem just tell me. :)
I would like to know with my code how am I able to make my file upload required. Because codeigniter form validation set rules is for post only.
I am unsure on how to make the file upload a requirement on form submit so it checks if file is required. And lets me submit form if file is upload or something along those lines
The callback works fine but required function cannot get to work with file upload.
Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Store_add extends MX_Controller {
public function __construct() {
parent::__construct();
if (!$this->session->userdata('isLogged')) {
redirect('admin');
}
$this->load->model('admin/setting/model_store_add');
$this->load->model('admin/setting/model_store_get');
$this->lang->load('admin/setting/store_add', $this->settings->get('config_admin_language'));
}
public function index() {
// Title Language
$this->document->setTitle($this->lang->line('heading_title'));
$this->load->library('form_validation');
$this->form_validation->set_rules('config_image', 'Store Image', 'callback_do_upload_image');
if ($this->form_validation->run($this) == FALSE) { // "$this is for HMVC MY_Form_validation"
return $this->load->view('setting/store_add.tpl');
} else {
$store_id = $this->model_store_add->add_store();
$this->do_upload_image($store_id);
$this->session->set_flashdata('success', $this->lang->line('text_success'));
redirect('admin/setting/store');
}
}
public function do_upload_image($store_id) {
$config['upload_path'] = './image/upload/';
$config['allowed_types'] = $this->settings->get('config_file_ext_allowed');
$config['max_size'] = $this->settings->get('config_file_max_size');
$config['overwrite'] = $this->settings->get('config_file_overwrite');
$config['max_width'] = '*';
$config['max_height'] = '*';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('config_image')) {
$this->load->library('form_validation');
$this->form_validation->set_message('do_upload_image', $this->upload->display_errors('<b>config_image</b>' .' '));
return false;
} else {
if ($store_id) {
$this->model_store_add->add_config_image($store_id, $this->upload->data());
}
}
}
}
Sample View form
<div class="panel-body">
<?php $data = array('id' => 'form-store-add', 'role' => 'form', 'class' => 'form-horizontal' );?>
<?php echo form_open_multipart('admin/setting/store/add', $data);?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<?php echo validation_errors('<div class="alert alert-danger">', '</div>'); ?>
<?php echo $this->load->view('setting/store_flashdata.tpl');?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-image"><?php echo $entry_image; ?></label>
<div class="col-sm-10">
<input type="hidden" name="config_image" value="<?php echo set_value('config_image', '');?>">
<input type="file" name="config_image" size="20"/>
</div>
</div>
<?php echo form_close();?>
</div>
WORKING NOW: I did more research on http://php.net/ I have fixed form validation for file upload made sure it is required I added is_file_upload and also added set form validation message with a return of false
public function do_upload_image($store_id) {
$config['upload_path'] = './image/upload/';
$config['allowed_types'] = $this->settings->get('config_file_ext_allowed');
$config['max_size'] = $this->settings->get('config_file_max_size');
$config['overwrite'] = $this->settings->get('config_file_overwrite');
$config['max_width'] = '*';
$config['max_height'] = '*';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (is_uploaded_file($_FILES['config_image']['tmp_name'])) {
if (!$this->upload->do_upload('config_image')) {
$this->load->library('form_validation');
$this->form_validation->set_message('do_upload_image', $this->upload->display_errors('<b>config_image</b>' .' '));
return false;
} else {
if ($store_id) {
$this->model_store_add->add_config_image($store_id, $this->upload->data());
}
}
} else {
$this->form_validation->set_message('do_upload_image', 'Image Required');
return false;
}
}
I am trying to implement a post functionality and want to pick message and image from a php view. I am receiving an error Message: Undefined index: image although i have defined it in my view. this is my view
<?php echo form_open_multipart('search/post_func');?>
<div id="your_post">
<div id="post_image">
<img id ="post_img" src="<?php echo $this->config->item('base_url'); ?><?php echo '/application/css/'. $img ?>"/>
</div>
<textarea name="post" rows="5" cols="30" placeholder="Share an update..." id="post_text" rows="2" value=""></textarea>
<div class="liveurl-loader"></div>
<div id="clip">
<input name="image" type="file" id="attach" /> <!--THIS IS IMAGE-->
</div>
<div class="liveurl" id="edited">
<div class="close" title="Entfernen"></div>
<div class="inner">
<div class="details">
<div class="image" id="img_dis"> </div>
<div class="title" id="title"> </div>
<div class="description" id="desc"> </div>
<div class="video"></div>
</div>
</div>
</div>
<div id="wraper_thin">
<select name="share_with" class="select_this" >
<option value="public">Share with: public</option>
<option value="connections">Share with: connections</option>
</select>
<button id="share" type="submit">Share</button>
</div>
</div>
</form>
this is my controller function where the problem is occurring
function post_func()
{
session_start();
echo $post_message=$_POST['post'];
echo $share_with=$_POST['share_with'];
echo $image=$_POST['image'];//ERROR IS HERE
if($image==null){
echo "<br/>no image<br/>";
}
else{
////////////////////////////////////////////////////////////////////////////////////////////////
$config['upload_path'] = './application/css';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$file = $_FILES['image']['image'];
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
echo "<br/>";
echo $this->upload->display_errors();
echo "<br/> image error<br/>";
}
else
{
echo "<br/> reached <br/>";
session_start();
$this->membership_model->insert_images($this->upload->data(),$email);
$data = array('upload_data' => $this->upload->data());
echo "<br/ problem<br/>";
}
///////////////////////////////////////////////////////////////////////////////////////////////
}
$public;
if($share_with=="public"){
echo "1";
$public=true;
}else{
echo "0";
$public=false;
}echo "-----------------------------<br/>";
echo $user=$this->session->userdata('user_identification');
$data = array
(
'userid'=> $user,
'public' => $public,
'message' => $post_message,
'picname' => "None"
);
$this->load->model('membership_model');
$this->membership_model->add_message($data);
echo "</br>";
echo $user=$this->session->userdata('user_identification');
}
I am confused about why the error is happening. Please HELP me.
It will be $_FILES
$image = $_FILES['image'];
print_r($image);
It will return an array so you need to print it.All the files,images which you are upload through the file type they all will be handeled by $_FILES and makesure that your form will be multipart like
<form enctype='multipart/form-data'>
<input type="file" name="image">
</form>