Vahid Najafi
Vahid Najafi

Reputation: 5263

Codeigniter upload: return uploaded picture's url

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

Answers (2)

Brian Ray
Brian Ray

Reputation: 1492

try using base_url().

$uploadData = $this->upload->data();

$fullPath = base_url() .'upload/'. $uploadData['file_name'];

Upvotes: 2

Samosa
Samosa

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

Related Questions