Welcome Guest, Not a member yet? Register   Sign In
Image Upload
#1

[eluser]MMCCQQ[/eluser]
hi im workin in a proyect with CI. i dont know how upload a image to a Folder.

i need to know how create a Folder with CI
ex:

image/username/username.jpg

image/MMCCQQ/MMCCQQ.jpg
#2

[eluser]Michael Wales[/eluser]
PHP.net: mkdir()
#3

[eluser]MMCCQQ[/eluser]
[quote author="walesmd" date="1187298203"]PHP.net: mkdir()[/quote]

i know use mkdir but how can i integrate with CI?
#4

[eluser]Derek Allard[/eluser]
consider the file helper.

write_file('path', $data)
Quote:Writes data to the file specified in the path. If the file does not exist the function will create it.
#5

[eluser]batteries[/eluser]
I apologize in advance for being so blunt, but RTFM
#6

[eluser]MMCCQQ[/eluser]
<form action="register" method="POST" enctype="multipart/form-data" >
<table>
<tr>
<td class="sti" >Your Avastar:</td>
<td>&lt;input type="file" name="user_pic"/&gt;</td>
</tr>

</table>

&lt;input type="submit" id="button" value="Upload" /&gt;


&lt;/form&gt;

how i get user_pic file?
#7

[eluser]MMCCQQ[/eluser]
i got this function


Code:
function Upload()
    {
     $id = $this->session->userdata('id');
     $data = 'Some file data';
     write_file('./home/tunerspo/public_html/img/'.$id.'/index.php', $data);

        $config['upload_path'] = './home/tunerspo/public_html/img/'.$id.'/index.php';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
        
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $this->load->view('upload_success', $data);
        }
    }

create a folder with the id of the member. will work?
#8

[eluser]MMCCQQ[/eluser]
dont work with this
$config['upload_path'] = "/home/txxx/public_html/img/".$id;

and work without ; $id

but i need to know the id of img ex: /img/15/MMCCQQ_thumb.jpg
Code:
$config['upload_path'] = "/home/txxx/public_html/img/".$id;
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
#9

[eluser]gunter[/eluser]
Code:
_function Init_Directories($dir)
    {
        $direxplode= explode("/", $dir);
        $hello="";
        foreach ($direxplode as $a)
            {//    echo "<br> file exist? ".$hello;
                $hello.=$a;                
                if(file_exists($hello)) {} else
                {
                    if (
                        mkdir ($hello,0777))
                        echo "folder created: ".$hello."<br>");
                }
                $hello.="/";                
            }
    }



I found an old function, I hope it works
call it with:
Code:
$uploadPath ='this/is/the/path/that/will/be/created/image/username';
$this->_Init_Directories($uploadPath)
first it will create:
this
this/is
this/is/the...
and so on
#10

[eluser]MMCCQQ[/eluser]
how i add the "id"?

i cant do this
Code:
= "/home/txxx/public_html/img/".$id;




Theme © iAndrew 2016 - Forum software by © MyBB