Some times we need to create a download link of any file in our site. We can point a direct link of the file to download but in this case we can get the absolute path of that file which is not preferred to us. Moreover some browsers redirect the download link path in a new window.
Hence we can create a separate PHP script through which we can download any file and there will be no possibility to access the absolute path of the file and no redirection to the other page. We can get the save file pop window in the same window.
Step 1: Create a PHP file named download.php and put the following codes in it.
Step 2: Now wherever you want to put the download file link, put the following code:
<a href="download.php?filename=yourfilename.zip">Click here to Download the File</a>
Generally we fetch data from MySQL table and display the fetch records in rows one by one. But sometimes we need to display the records horizontally as per the image below.
|Sir Isaac Newton
||Jesus of Nazareth
It’s not a tough job. You can see that the records are pulling up and displaying 2 records in a row and after that in the next rows for the next 2 records. The code for such display style is as follows:
Many a time we need to create thumbnails of the uploaded images on the fly. In PHP we can create thumbnail at the time of uploading image.
The PHP functions you need to know about for this script.
Steps to generate thumbnails.
- Make a folder named ‘images’ inside your web directory.
- Make a sub folder named ‘thumbs’ inside‘images’ folder’.
- Create a PHP page for example‘thumbnail.php’ inside your root folder.
- Now place the following codes in‘thumbnail.php’.
It’s done. Now run the thumbnail.php file through your browser http://yourdomain.com/thumbnail.php