Reputation: 5263
I have a upload input, And I want to save the url into the database.
How can I get picture's url in codeigniter?
Codeigniter file uploading just return these:
[file_path] => /path/to/your/upload/
[full_path] => /path/to/your/upload/jpg.jpg
I want to have link of image, like:
www.example.com/path/someWhere/picture.jpg
Thanks.
Upvotes: 0
Views: 2861
Reputation: 1492
try using base_url()
.
$uploadData = $this->upload->data();
$fullPath = base_url() .'upload/'. $uploadData['file_name'];
Upvotes: 2
Reputation: 845
I don't know the context but you should be doing something like this :-
First set the media_url in config.
$config['media_url'] = "http://example.com/media/path/"
Then in the upload script :-
$upload_data = $this->CI->upload->data();
return $this->CI->config->item('media_url').$upload_data['file_name'];
Upvotes: 2