Download file with mac


i try to export data from my database to my computer with the CSVExport extension, a mac. For this, i put in my code (controller):

$filename = '/Users/brice/downloads/Groupe'.$group_id.'.csv';

$content = $csv->toCSV($filename, ",", "\"");              

When i use my application in localhost, it works fine, but when i try this functionnality in a distant server, i get the error message:

file_put_contents(/Users/brice/downloads/Groupe38.csv): failed to open stream: No such file or directory 

I tried several codes (//Users instead of /Users, /Macintosh HD/Users, …) but none works for my mac. I changed the access rights (all permits for all in the repository), but it doesn’t work better for this…

I’m using SSL access, but i don’t think this is the problem cause my uploads are working.

Did someone know the good way to describe mac destination?

I develop only on mac. If any php or mysql version is a problem.

Your error is a file location error. It’s not fonding the file

Thank you for your response,

the thing is that’s working on localhost but not on distant server, maybe i’m forgetting to declare my local drive for the application, but i don’t really understand if i need to and how to do that?


I have never tried a direct download from the seever to my mac/macine. Normaly I use my browser or ftp into the server to get the file.

Check your server directory setting and then save the file to your server, then grab the file by ftp.


Are you sure you have access to load files outside your web directory? Check open_basedir variable.

Thank you SapporoGuy and wisp, i will try to do the download in 2 steps.

Just to end, it work with this code in my controller:


// dans un premier temps, on place le fichier sous /protected/downloads

			$dir = Yii::getPathOfAlias('application.downloads');

			$filename = $dir.'/Groupe'.$group_id.'.csv';

			$content = $csv->toCSV($filename, ",", "\"");          


// on va ensuite transferer le fichier sur le poste local

			return Yii::app()->getRequest()->sendFile(basename($filename), @file_get_contents($filename));

// suppression du fichier en fin de traitement