Have you ever came across a situation where you wanted an image to download instead of having the browser to display it? This is how you can do it . Enter the following code in a php file foo.php and call it like foo.php?file=myimage.jpg. Then a browser save dialog box will appear.
PHP:
-
if(!
$_GET['file']){exit;
}
-
-
-
header('Content-Type: image/jpg');
-
header('Content-Disposition: attachment; filename='.
$file);
-
If you want to do the same with other kind of files like video etc, just replace the 'image/jpg' above with on of the following:
"pdf": "application/pdf"
"exe": "application/octet-stream"
"zip": "application/zip"
"xls": "application/vnd.ms-excel"
"ppt": "application/vnd.ms-powerpoint"
"gif": "image/gif"
"png": "image/png"
"jpg": "image/jpg"
"mp3": "audio/mpeg"
"mp3": "audio/mp3"
"wav": "audio/x-wav"
"mpe": "video/mpeg"
"mov": "video/quicktime"
"avi": "video/x-msvideo"
Posted in apache, php.
By msti
– February 21, 2007
BrainOff explains how he used the cakephp framework for building a simple application with CRUD administration and a Searchable front end. The application is used by the UN INSTRAW researchers.
Posted in cakephp, php.
By msti
– February 20, 2007

View original post here.
Posted in cakephp.
By msti
– February 10, 2007
There were times when I wanted to use Joomla! and integrate it with new functionalities. The best option would be to create new components for joomla, but I never got to do this, did not want to invest time in this. Now, that belongs to the past. I just discovered this article by Max aka Abhimanyu Grover. He illustrates how to install joomla! within the cakephp framework and take all the advantages of cake while at the same time you get the user authentication and content management that joomla! offers. Great article, take a look.
Posted in Joomla!, cakephp, php.
By msti
– February 9, 2007
You can use recursive or unbind whenever you want to unbind associations from models. This is very useful because there are cases when you want to execute a simple query and you do not want to join other tables. Here comes unbind. Unbind allows us to unbind all but some model associations. On the other hand if you want to unbind all associations you can use recursive like this:
PHP:
-
$this->Model->recursive = -1;
CakePHP is beautiful. I love it!
Posted in cakephp, php.
By msti
– February 9, 2007
Recent Comments