Welcome Guest, Not a member yet? Register   Sign In
How to change Uploded File name?
#11

[eluser]Thorpe Obazee[/eluser]
You can probably post some code so that people can see?
#12

[eluser]cmark[/eluser]
[quote author="bargainph" date="1242298126"]You can probably post some code so that people can see?[/quote]

Sure!

Code:
...
// saving the image:
$config['file_name'] = $this->model->getID(); // 6
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';

$this->load->library('upload', $config);

$this->upload->do_upload("imagen");
...

The image is uploaded succesfully, but in the upload folder, the file name is other than the setted in $config['file_name'].
#13

[eluser]Thorpe Obazee[/eluser]
what is the filename produced?
#14

[eluser]cmark[/eluser]
My answer: http://ellislab.com/forums/viewreply/551928/

Thanks Smile
#15

[eluser]Thorpe Obazee[/eluser]
Nice. Searching helps a lot Smile
#16

[eluser]Zorancho[/eluser]
I am doing it this way:
First i create a folder at the same level as the system folder, example: uploads
Then i initialize the library (in the controller) like in the user guide:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if($this->upload->do_upload('name_of_the_input_file_in_the_form'))
{
$picture = $this->upload->data();
rename('./uploads/'.$picture['file_name'], './uploads/new_name.'.$picture['file_ext']);
}
I hope this helps anyone, of course you can do more checking, but that's the beauty of the CI, it gives you pretty good basic start, so you can learn more php along the way Smile




Theme © iAndrew 2016 - Forum software by © MyBB