Bonjour
Je voudrais obliger mon utilisateur à enregistrer un fichier ou à l'ouvrir sans avoir accès au chemin où le fichier est stocké.
Pour faire ceci. J'ai ecrit ce code dans mon controlleur(Le code a été simplifié au maximum)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public function modifAction ()
{
	$modif = $this->_request->getParam('nu', 0);
 
		$modifexists = new cDetailsModifs();
		$resultat = $modifexists->fetchRow($modifexists->select()->where('modif = ?',$modif));
		if (!$resultat) {
			$this->view->message="Aucune modification ne correspond à votre demande.";
		    $this->view->erreur=true;
		    return;
		}else {
			....
			$dir='C:\sites\www\manufacturing\html\upload\modifs\\';
			$this->view->fichier=$dir.$modif.$resultat->ext_fichier;
 
		}			
 
 
 
}
Ensuite, j'ai mis dans mon view modif.phtml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\'".$this->fichier."\'\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
 
?>
Lorsque je tape l'URI http://localhost/manufacturing/html/...f/nu/0022ext08, j'obtiens la boite de dialogue "Ouvrir, Enregistrer, Annuler' mais la page qui s'ouvre dans excel correspond réellement au contenu généré dans ma vue modif.phtml et non pas à mon fichier '0022ext08.xls'.