Sending CSV File Download link through mail on ipad

Hello All,

  I have Created Code to generate the CSV File using EExcel View. I can successfully download as wellas save the file on my server, Now What I Want is that, When user downloads CSV File from IPad it gets open in safari, and if he mails the same file, I want to send the download link which is path of the saved CSV Files on my server.

Currently I am getting the link as my url with controller and action.

Please suggest me some solution, Download of CSV on IPadwill also work for me.

Here is the code from EExcelView


if(!$this->filename)

						$this->filename = $this->title;

					$this->cleanOutput();

					$targetPath     = Yii::getPathOfAlias('webroot').'/files/'; 

                                        $objWriter->save($targetPath.$this->filename.'.'.$this->mimeTypes[$this->exportType]['extension']);

                                        

                                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

					header('Pragma: public');

					header('Content-type: '.$this->mimeTypes[$this->exportType]['Content-type']);

					header('Content-Disposition: attachment; filename="'.$this->filename.'.'.$this->mimeTypes[$this->exportType]['extension'].'"');

					header('Cache-Control: max-age=0');				

					$objWriter->save('php://output');

                                        

                                        ob_start();

					Yii::app()->end();

					ob_end_clean();

Well… i have figured out the solution steps are as follows

  1. When User clicks on the export button check the user agent

  2. If The user agent is ipad, iphone, ipod then instead of streaming out the CSV to browser, save it to server

  3. Now Using some javascript snippet force-link-to-open-in-mobile-safari-from-a-web-app-with-javascript open new window in ipad.

  4. and then set the downloaded file link in the ipad browser so that ipad user will get file which is actually saved on the server.

  5. In between , implementation is totally part of your logic…

:)