<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>imageUpload.php by Florence Latour v.2.1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> </head> <body> <?php # You can find a french version of this classes on http://www.luciolab.com/equipe-labo
#1# use the file require 'imageUpload.php';
//You can use timestamp or an other variable in order to name your image. You can use a select for the quality $timestamp = time(); $quality = $_POST['quality_img']; $max_size = '5250000';
#2# Create the new object /* Notice : ImageUpload ($input_file, $directory, $max_dimension, $side, $new_name, $quality) 1 - $input_file : the name of your input type="file" 2 - $directory : you have to put the / at the end like this -> images/ (if the directory isn't exist, the class will create it) 3 - $max_dimension : a number only (value is px) 4 - $side : only 2 choices -> height/width 5 - $new_name : the name of the picture in your directory, don't specify the type (if the file already exist, the class will erase it before to create the new one) 6 - $quality : quality of the picture -> a number between 0 (low) to 100 (high) 7 - $max_size : maximal weight allowed (octets) */
$test_image = new ImageUpload ('input_picture', 'images/', '300', 'width', $timestamp.'_image', $quality, $max_size);
#3# Use the functions $test_image -> uploadImg (); // upload $name_image = $test_image -> getNameImg(); // get the new name of you image $test = $test_image -> getExplanation(); if (empty($test)) { echo 'Your image has been successfully updated'; } else { echo $test; // You can change the text in imageUpload.php } ?>
<div id="cosmo"> <form enctype="multipart/form-data" action="" method="post"> <!-- Picture --> <label for="input_picture">Select the picture</label> <input type="file" name="input_picture" id="input_picture" tabindex="1" /> <!-- Quality --> <label for="quality_img">Select the quality</label> <select name="quality_img" id="quality_img" tabindex="2"> <option value="30">Low</option> <option value="50">Mean</option> <option value="75">High</option> <option value="100">Excellent</option> </select>
<input type="submit" name="submit" id="submit" value="Submit" tabindex="3" /> </form> </div> </body> </html>
|