1
i made a function to upload files and this works properly, now in my view I added a link to download the file.
link in view:
<td><?php echo anchor("propostas/download/{$id}/{$record->nomepessoal}", "<i class='glyphicon glyphicon-arrow-down'></i>", ['class' => 'btn btn-primary btn-block', 'name' => 'baixar']); ?></td>
and this is the function
of controller
// baixar anexo
public function download($id, $nomepessoal) {
$this->load->helper('download');
$nomearquivo = $nomepessoal."_".$id.".zip";
$path = file_get_contents(base_url()."anexos/".$nomearquivo);
force_download($path, null); // start download`
}
Error in function file_get_contents
:
Message: file_get_contents(http://localhost/system/attachments/arquivo_17.zip): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Note: the file exists and the name is correct.
I set a rule
Um sistema em cada VirtualHost
and create an internal domain in my development environment, like http://sistema1.local/ and configure my archive/etc/hosts
for my machine to recognize that domain, so I never wrote the Rewritebase line :)– Samuel Fontebasso
@I edited it according to your guidance. I will pay attention to these details, although I was focused on making it work with what he presented and the url of the attachment is
http://localhost/sistema/anexos/arquivo_17.zip)
then I believe that Rewriteengine should point to the directory/sistema
localhost is not right?– Samuel Fontebasso
Let me put it another way: if
sistema
is the "root" of CI3, so this right, but is redundant, will work with or without, however even if it is redundant and does not affect anything, in the server/hosting the folder scheme may be totally different and so there yes can fail. There is no need to use Rewritebase unless you want the Rules to actually point to a folder that is totally different from the current one. + 1 for your answer, now I think you look great.– Guilherme Nascimento
Perfect! I think I finally understand what Rewritebase is about and why it always worked without me, I never wanted it to point elsewhere! Thank you.
– Samuel Fontebasso