Welcome To Favicon Maker!
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
// If we have uploaded correctly...
$extensions = array("JPG","jpg","JPEG","jpeg"); //File Types
$check = $target_path;
$explosion = explode(".", $check);
$name = $explosion[0]; //This is the real name of the file
$extension = $explosion[1]; //This is the extension of the full file
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
if (!in_array($extension, $extensions)) {
echo "You have to upload a file ending in .jpg in order for us to generate your favicon";
unlink ($target_path); // delete the original file
} else {
echo "We have successfully generated your icon!
";
// Now actually generate it
$im = imagecreatefromjpeg($target_path);
list($width, $height) = getimagesize($target_path); // get the width and height of the jpg
$image_p = imagecreatetruecolor("16", "16"); // create a 16x16 canvas to play with
imagecopyresampled($image_p, $im, 0, 0, 0, 0, "16", "16", $width, $height); // resize jpg to 16x16
$num = rand (1,99999); // generate a random number between 1 and 99999
$output = $num."-favicon.ico"; // add the number to a string with -favicon.ico
imagepng($image_p,$output); // make a .png file (icon file) from our data
imagedestroy ($im); // close gd library
echo "
Right click on the image and choose save. Save the image as favicon.ico and then upload into your base directory"; // show our icon with information
unlink ($target_path); // delete the original file
}
} else{
echo "Upload a .jpg file to convert it to a favicon!";
}
?>
$imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2000); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*3000); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*1000); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2200); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2400); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2800); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*1800); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2100); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*2900); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?> $imglist=''; //$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/ // see that you don't forget about the "/" at the end $img_folder = "./"; mt_srand((double)microtime()*1700); //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners) while ($file = $imgs->read()) { if (eregi("ico", $file)) $imglist .= "$file "; } closedir($imgs->handle); //put all images into an array $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; //generate a random number between 0 and the number of images $random = mt_rand(0, $no); $image = $imglist[$random]; //display image echo ''; ?>