CodeIgniter Forums
$this->input->post() help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->input->post() help (/showthread.php?tid=38243)



$this->input->post() help - El Forum - 02-02-2011

[eluser]minagabriel[/eluser]
hello guys iam trying to upload an image and i my view is
Code:
<?php echo form_open('photo/do_upload'); ?>
photos : <input type="text" name="name" />
photo caption : <textarea name="mytext" cols="30" rows="5">
please add your caption here </textarea>
<label for="file"> file name : </label>
&lt;input type="file" name="file" id="file"/&gt;
&lt;input type="submit" name="submit" value="upload" /&gt;
&lt;/form&gt;
&lt;/form&gt;

how can i pass the image data like size , name etc
i used
$this->input->post('file') and it echo the image name for me

my question is how do i get $_file['file']['size'] to my controller ?
thnx all


$this->input->post() help - El Forum - 02-02-2011

[eluser]JuanitoDelCielo[/eluser]
Ypu need a multi part form, check the form helper adn de file upload class


$this->input->post() help - El Forum - 02-02-2011

[eluser]minagabriel[/eluser]
i dont want to use any helper i just want to use a plain php


$this->input->post() help - El Forum - 02-03-2011

[eluser]Cristian Gilè[/eluser]
As JuanitoDelCielo said you need the enctype="multipart/form-data" property in the form tag. This is necessary for PHP file to function properly.

Code:
&lt;?php echo form_open_multipart('photo/do_upload'); ?&gt;

The $_FILES array is where PHP stores all the information about uploaded files. In the controller you can access the file name and the file size with

Code:
$_FILES['file']['name']

and

$_FILES['file']['size']


Cristian Gilè


$this->input->post() help - El Forum - 02-03-2011

[eluser]minagabriel[/eluser]
this is very strange

why when i use $_FILES it works and when i use $_files it doesnt
is it case sensetive ?