Welcome Guest, Not a member yet? Register   Sign In
need some help with uploaded file extensions
#1

[eluser]Unknown[/eluser]
I'm trying to upload a file while changing the filename, and at the same time insert the new filename with the corresponding extension in a database together with some other data., everything works except adding the correct extension to the filename for the database. I've tried pretty much everything but nothing seems to work.

this is my model
Code:
function do_upload()
    {    
        $gamename = $this->input->post('gamename');
        $config = array(
            'file_name' => $gamename,
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->games_path,
            'max_size' => 2000,
            'max_width' => 1024,
            'max_height'=> 768
        );
        
        $this->load->library('upload',$config);
        $this->upload->do_upload();
        
        $image_data = $this->upload->data();
        
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $this->games_path . '/thumbs',
            'maintain_ration' => true,
            'width' => 150,
            'height' => 150
        );
        
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
    }
    
    function create_game()
    {
        $new_game_insert_data =
        array(
            'name' => $this->input->post('gamename'),
            'author' => $this->input->post('author'),
            'course' => $this->input->post('course'),
            'description' => $this->input->post('description'),
            'image' => $this->input->post('gamename').'.ext'
        );
        
        $insert = $this->db->insert('games', $new_game_insert_data);
        return $insert;
    }

I was also wondering if it would be possible to create 2 empty folders at the same time as uploading the picture

any help will be greatly appreciated
#2

[eluser]InsiteFX[/eluser]
The filenames are stored in the $_FILES[] array.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB