Welcome Guest, Not a member yet? Register   Sign In
Is there any way to download a image when it is clicked?

I don't know why it's changing from dot to underscore but I believe something should be change in your Apache config, In my experience CI never worked good in a local server running multiple sites without configuration. If you want to try, add a site following the instructions in point A, otherwise jump to the test at the end of my post (point B).

A) You should create a file in sites-available/ where you set the Document Root and the Server Name:

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin [email protected]
  ServerName  test.local
  #ServerAlias www.test.local

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.php
  DocumentRoot /var/www/your_local/httpdocs/

  # Custom log file locations
  LogLevel warn
  CustomLog /var/www/your_local/logs/access.log combined
  ErrorLog /var/www/your_local/logs/error.log


Change the hosts file, so your browser will point to the local CI installation:

Code: test.local

And use a2ensite to set the new config, after that you should restart your server:

/etc/init.d/apache2 restart

After that you should be able to call uri like this:


This makes the local CI installation available from the other workstations on the same lan, just update the hosts on each workstation with the ip of the server:

Code: test.local

B) Do a test, change:

$data = file_get_contents($this->input->server('DOCUMENT_ROOT') . 'uploads/galeriasFotos/' . $this->uri->segment(3));
$name = $this->uri->segment(3);


$data = file_get_contents('');
$name = 'image.jpg';

If goes fine than, in the original, try to change uri->segment() to 4, or give a check to your base_url in config.php
With file_get_contents you can use the DOCUMENT_ROOT or the uri, but the write one should be

base_url() . 'download/image/' . $this->segment->uri(3)

Other than this I don't know how to help you. Bye.

Messages In This Thread
Is there any way to download a image when it is clicked? - by El Forum - 12-24-2010, 08:26 AM

Theme © iAndrew 2016 - Forum software by © MyBB