kmf
kmf

Reputation: 137

Remame image upload to username in Codeigniter

In the site I've been working on, I do have this feature where the user could upload his/her profile picture. When the user will click upload button, I want the file to be renamed to his/her username when uploaded.

I tried fetching the user's username from the database and assigning it as a name of the file to my view, but it didn't work.

<?php echo "<input type='file' name='".$row->username."' size='20' id='file' required/>"; ?>

And I think it's wrong. I also tried to get the value of data from an array from the model but it didn't work. I am really new to codeigniter, and this is my first time to encounter such things.

Upvotes: 0

Views: 33

Answers (1)

kmf
kmf

Reputation: 137

$config['file_name'] = $this->session->userdata('username');

Upvotes: 1

Related Questions