Welcome Guest, Not a member yet? Register   Sign In
Cant get photo to upload.
#1

Im trying to create an advert template but can not get the photos to upload. I dont receive any errors. Ive simplified the coding so that it focuses only on the uploading of one photo, as follows;

This is the Controller coding;
PHP Code:
public function drinkadvert()
    {
    
$this->load->library('image_lib');
    
$this->load->helper(array('form','file'));
    
$this->load->library('upload');

        
$lcuser $this->session->userdata('user_name');
        
$drink $this->input->post('dri');
        
$drinkphoto $this->input->post('drinkphoto');

        {
        
$this->load->view('affairs/drinkadvert');
        }

        
$config['upload_path'] = 'mem/'.$lcuser.'/adverts/'.$drink;
        
$config['allowed_types'] = 'png|jpg|jpeg';

        
$this->upload->initialize($config);

        if(
$this->upload->do_upload("$drinkphoto"))

        {
        
$img $this->upload->data();
        
$drinkphoto 'mem/'.$lcuser.'/adverts/'.$drink/$img['file_name']; //The problem may lie in the file_name but I dont know much about that.
        
}
    }

public function 
upload_drinkphoto($str)
    {
    
$allowed_mime_type_arr = array('image/png','image/jpg','image/jpeg');

    if(isset(
$_FILES['drinkphoto']['name']) && $_FILES['drinkphoto']['name']!="")
        {
            
$mime get_mime_by_extension($_FILES['drinkphoto']['name']);

        if(
in_array($mime$allowed_mime_type_arr))
            {
            return 
TRUE;
            }
            else
            {
            
$this->form_validation->set_message('upload_drinkphoto''Upload in png/jpg/jpeg format');
            return 
FALSE;
            }
        }
    } 
This is the view coding.
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
?>
<body>

<?php echo form_open_multipart('drinkadvert'); ?>

<style type="text/css"> .drinkpic { position: fixed; width: 28%; right: 8%; top: 34%; background-color: White; } </style>
    <div class="drinkpic"> <input type="file" name="drinkphoto" id="drinkphoto" style="width: 100%; height: 5mm"; > </div>

<style type="text/css"> .sub { position: fixed; width: 5%; right: 19%; text-align: center; top: 83.5%; } </style>
    <div class="sub"> <input type="submit" value="Submit"></form></div> 

The remedy to this problem must be simple. Can anybody tell me what it is?
Reply


Messages In This Thread
Cant get photo to upload. - by christaliise - 10-02-2020, 08:08 AM
RE: Cant get photo to upload. - by InsiteFX - 10-02-2020, 06:56 PM
RE: Cant get photo to upload. - by christaliise - 10-03-2020, 01:27 AM
RE: Cant get photo to upload. - by InsiteFX - 10-03-2020, 02:40 AM
RE: Cant get photo to upload. - by christaliise - 10-03-2020, 04:22 AM
RE: Cant get photo to upload. - by christaliise - 10-03-2020, 06:42 AM
RE: Cant get photo to upload. - by InsiteFX - 10-03-2020, 07:20 AM
RE: Cant get photo to upload. - by christaliise - 10-03-2020, 07:56 AM
RE: Cant get photo to upload. - by InsiteFX - 10-03-2020, 10:20 AM
RE: Cant get photo to upload. - by christaliise - 10-03-2020, 04:49 PM
RE: Cant get photo to upload. - by christaliise - 10-04-2020, 01:34 AM
RE: Cant get photo to upload. - by InsiteFX - 10-03-2020, 05:25 PM
RE: Cant get photo to upload. - by coder987 - 10-12-2020, 01:40 AM
RE: Cant get photo to upload. - by christaliise - 11-16-2020, 10:00 AM
RE: Cant get photo to upload. - by christaliise - 12-02-2020, 10:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB