On my previous post I was shown how to shorten URL using Bitly API key. As well as Google also provide URL shorten service (goo.gl) for its users. In this post I show you how to shorten URL using Google URL shorten API. To working with this API you will need to get a Google URL Shorten API key. If you do not have get one from here for free.
There are several ways to grab file extension (E.g, 'txt' from 'my.txt') using PHP. You can use anyone from flowing. But I prefer to use pathinfo function, because it is PHP's build in function to grab file path information and others are string functions.
We can get a file's size by using PHP build in filesize function. But the problem is this function only works for local file. If you want to get a remote file's size you need to think some other way. In this post I am going to show you how we can get a remote file's size from it's header information. Here we go..
If you want to generate random numbers, it is possible by using PHP’s rand function. But if you want to generate random string, it is not possible by using rand function. Because rand function only returns numbers as integer between two values. I coded a simple PHP function that works exactly same as rand function but the deference is it returns strings. You can use it in captcha function, random password generator or anywhere else.
Google strongly guide webmasters to make there website URLs SEO friendly or Google friendly. Creating URL from title is the best way to make URLs more user or search engine friendly. This simple function can make clean and friendly URL slug from ugly to uglier title or string.
HTML 5 allows you to upload a complete directory by using directory attribute. This method is more user friendly then any other file uploading method. Because we can upload a complete directory at a time. Till now this method is working well only in Chrome and webkit browser by using webkitdirectory attribute we can also add mozdirectory attribute for mozila browser support. Here is a simple example to upload directory using PHP.
Image re-size while upload can save your web serve's space and bandwidth both by compressing and reducing image size and dimension. I have coded a simple PHP script to re-size image into several dimensions while it is been uploaded.