%PDF- %PDF-
Direktori : /home/devcapijob/public_html/gestion/liberary/ |
Current File : /home/devcapijob/public_html/gestion/liberary/uploadifys.php |
<?php /* Uploadify Copyright (c) 2012 Reactive Apps, Ronnie Garcia Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */ // Define a destination $date=date('Ymd_His').'_'; $targetFolder = $_POST['folder']; // Relative to the root //$targetFolder = $_POST['folder']; if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] .'/'. $targetFolder; $name_part = explode('.',$_FILES['Filedata']['name']); if($name_part!=0){ $ext = $name_part[count($name_part)-1];} $nom_fichier=genere_alias(substr($_FILES['Filedata']['name'], 0, -strlen($ext))); $nom_fichier = $nom_fichier.'.'.$ext; $targetFile = rtrim($targetPath,'/') . '/' . $date . $nom_fichier; $name=$date . $nom_fichier; // Validate the file type $fileParts = pathinfo($_FILES['Filedata']['name']); if(move_uploaded_file($tempFile,$targetFile)){ redimensionner_image($targetFile, 200); }; echo $name; } function randomname($lenth =5) { $aZ09 = range(0, 9); $out =''; for($c=0;$c < $lenth;$c++) { $out .= $aZ09[mt_rand(0,count($aZ09)-1)]; } return $out; } function genere_alias($string){ //remove any '-' from the string they will be used as concatonater $str = str_replace('-', ' ', $string); $str = htmlentities(utf8_decode($str)); $str = preg_replace(array('/ß/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'),array('ss',"$1","$1".'e',"$1"),$str); // remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); // lowercase and trim $str= str_replace('--','-',$str); $str = trim(strtolower($str)); return $str; } function redimensionner_image($fichier, $nouvelle_taille) { //VARIABLE D'ERREUR global $error; //TAILLE EN PIXELS DE L'IMAGE REDIMENSIONNEE $longueur = $nouvelle_taille; $largeur = $nouvelle_taille; //TAILLE DE L'IMAGE ACTUELLE $taille = getimagesize($fichier); //SI LE FICHIER EXISTE if ($taille) { //SI JPG if ($taille['mime']=='image/jpeg' ) { //OUVERTURE DE L'IMAGE ORIGINALE $img_big = imagecreatefromjpeg($fichier); $img_new = imagecreate($longueur, $largeur); //CREATION DE LA MINIATURE $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur); //COPIE DE L'IMAGE REDIMENSIONNEE imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]); imagejpeg($img_petite,$fichier); } //SI PNG else if ($taille['mime']=='image/png' ) { //OUVERTURE DE L'IMAGE ORIGINALE $img_big = imagecreatefrompng($fichier); // On ouvre l'image d'origine $img_new = imagecreate($longueur, $largeur); //CREATION DE LA MINIATURE $img_petite = imagecreatetruecolor($longueur, $largeur); //COPIE DE L'IMAGE REDIMENSIONNEE imagecolortransparent($img_petite, imagecolorallocatealpha($img_petite, 0, 0, 0, 127)); imagealphablending($img_petite, false); imagesavealpha($img_petite, true); imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]); imagepng($img_petite,$fichier); } // GIF else if ($taille['mime']=='image/gif' ) { //OUVERTURE DE L'IMAGE ORIGINALE $img_big = imagecreatefromgif($fichier); $img_new = imagecreate($longueur, $largeur); //CREATION DE LA MINIATURE $img_petite = imagecreatetruecolor($longueur, $largeur) or $img_petite = imagecreate($longueur, $largeur); //COPIE DE L'IMAGE REDIMENSIONNEE imagecopyresized($img_petite,$img_big,0,0,0,0,$longueur,$largeur,$taille[0],$taille[1]); imagegif($img_petite,$fichier); } }} ?>