It looks like you're new here. If you want to get involved, click one of these buttons!
<cfif structkeyexists(\"form.filename\")>
<cfscript>
thisPath = ExpandPath(\"*.*\");
thisDirectory = GetDirectoryFromPath(thisPath);
FileDir = thisDirectory & \"uploads\";
</cfscript>
<cfif not DirectoryExists(FileDir)>
<cfdirectory action=\"create\" directory=\"#FileDir#\" mode=\"777\" >
</cfif>
<cffile action=\"upload\" filefield=\"fileData\" destination=\"#FileDir#\" nameconflict=\"makeunique\" mode=\"777\">
<cfimage action=\"resize\" height=\"100\" width=\"100\" source=\"#FileDir##file.serverFile#\" destination=\"#FileDir#t_#file.serverFile#\" overwrite=\"yes\">
<cfimage action=\"resize\" height=\"\" width=\"640\" source=\"#FileDir##file.serverFile#\" destination=\"#FileDir##file.serverFile#\" overwrite=\"yes\">
<cfscript>
FileDelete(FileDir & file.serverFile)
writeoutput(1);
</cfscript>
</cfif>
if (!empty($_FILES)) {
class Image {
var $uploaddir;
var $quality = 80;
var $ext;
var $dst_r;
var $img_r;
var $img_w;
var $img_h;
var $output;
var $data;
var $datathumb;
function setFile($src = null) {
$this->ext = strtoupper(pathinfo($src, PATHINFO_EXTENSION));
if(is_file($src) && ($this->ext == \"JPG\" OR $this->ext == \"JPEG\")) {
$this->img_r = ImageCreateFromJPEG($src);
} elseif(is_file($src) && $this->ext == \"PNG\") {
$this->img_r = ImageCreateFromPNG($src);
} elseif(is_file($src) && $this->ext == \"GIF\") {
$this->img_r = ImageCreateFromGIF($src);
}
$this->img_w = imagesx($this->img_r);
$this->img_h = imagesy($this->img_r);
}
function resize($w = 100) {
$h = $this->img_h / ($this->img_w / $w);
$this->dst_r = ImageCreateTrueColor($w, $h);
imagecopyresampled($this->dst_r, $this->img_r, 0, 0, 0, 0, $w, $h, $this->img_w, $this->img_h);
$this->img_r = $this->dst_r;
$this->img_h = $h;
$this->img_w = $w;
}
function createFile($output_filename = null) {
if($this->ext == \"JPG\" OR $this->ext == \"JPEG\") {
imageJPEG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext, $this->quality);
} elseif($this->ext == \"PNG\") {
imagePNG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
} elseif($this->ext == \"GIF\") {
imageGIF($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
}
$this->output = $this->uploaddir.$output_filename.'.'.$this->ext;
}
function setUploadDir($dirname) {
$this->uploaddir = $dirname;
}
function flush() {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
imagedestroy($this->dst_r);
unlink($targetFile);
//imagedestroy($this->img_r);
}
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file ($tempFile, $targetFile);
$image = new Image();
$image->setFile($targetFile);
$image->setUploadDir($targetPath);
$image->resize(640);
$image->createFile(md5($tempFile));
$image->resize(100);
$image->createFile(\"s_\".md5($tempFile));
$image->flush();
}
<script type=\"text/javascript\">// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader' : '../uploadify/uploadify.swf',
'script' : '../uploadify/uploadify.php',
'cancelImg' : '../uploadify/cancel.png',
'auto' : true,
'folder' : '../uploads'
});
});
// ]]></script>
function flush()
$image->flushe();
<?php
/******************************/
/* Cadi Web & Design */
/* Réalisation de CADI */
/* @_OPS_@ */
/* www.cadi-software.com */
/******************************/
error_reporting(E_ALL);
$width = 75;
$height = 100;
//$_FILES['fichier']['name'] = str_replace(\" \",\"_\",$_FILES['fichier']['name']);
//$urltxt = \"http://\".$_SERVER[\"SERVER_NAME\"].\"/news/news_images/\";
/*** the image file to thumbnail ***/
$image = $urltxt.$url; // Remplacer $urltxt.$url par le chemin du dossier
if(!file_exists($image))
{
echo '';
}
else
{
/*** image info ***/
list($width_orig, $height_orig, $image_type) = getimagesize($image);
/*** check for a supported image type ***/
if($image_type > 4)
{
echo 'invalid image';
}
else
{
/*** thumb image name ***/
$thumb = '../bureau/membre_img/thumbs/'.$url.'';
$img = $_FILES['fichier']['name'];
$ext = pathinfo($img, PATHINFO_EXTENSION);
/*** maintain aspect ratio ***/
if (($width_orig > $height_orig) && ($width_orig > $width)) {
$height = (int) (($width / $width_orig) * $height_orig);
} elseif($height_orig > 100) {
$height = 100;
} else {
$height = $height_orig;
}
if (($height_orig > $width_orig) && ($height_orig > $height)) {
$width = (int) (($height / $height_orig) * $width_orig);
} elseif($width_orig > 75) {
$width = 75;
} else {
$width = $width_orig;
}
/*** resample the image ***/
$image_p = imagecreatetruecolor($width, $height);
if(($ext == 'jpeg') || ($ext == 'jpg') || ($ext == 'JPEG') || ($ext == 'JPG')) {
$image = imagecreatefromjpeg($image);
} elseif ($ext == 'png') {
$image = imagecreatefrompng($image);
// fond transparent (pour les png avec transparence)
imagesavealpha($image_p, true);
$trans_color = imagecolorallocatealpha($image_p, 0, 0, 0, 127);
imagefill($image_p, 0, 0, $trans_color);
} elseif ($ext == 'gif') {
$image = imagecreatefromgif($image);
// fond transparent (pour les gifs avec transparence)
$red = rand(0,255);
$green = rand(0,255);
$blue = rand(0,255);
$transparent = imagecolorallocate($image_p, $red, $green, $blue);
imagefill($image_p, 0, 0, $transparent);
imagecolortransparent($image_p, $transparent);
imagetruecolortopalette($image_p, false, 256);
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
/*** write the file to disc ***/
if(!is_writeable(dirname($thumb)))
{
echo 'Impossible d\'enregistrer l\'image dans le dossier ' . dirname($thumb);
}
else
{
if ($ext == 'png') {
imagepng($image_p, $thumb, 9);
} elseif ($ext == 'gif') {
imagegif($image_p, $thumb, 100);
} else {
imagejpeg($image_p, $thumb, 100);
}
}
}
}
?>
ini_set('memory_limit', '100M');
if (!empty($_FILES)) {
class Image {
var $uploaddir;
var $quality = 80;
var $ext;
var $dst_r;
var $img_r;
var $img_w;
var $img_h;
var $output;
var $data;
var $datathumb;
function setFile($src = null) {
$this->ext = strtoupper(pathinfo($src, PATHINFO_EXTENSION));
if(is_file($src) && ($this->ext == "JPG" OR $this->ext == "JPEG")) {
$this->img_r = ImageCreateFromJPEG($src);
} elseif(is_file($src) && $this->ext == "PNG") {
$this->img_r = ImageCreateFromPNG($src);
} elseif(is_file($src) && $this->ext == "GIF") {
$this->img_r = ImageCreateFromGIF($src);
}
$this->img_w = imagesx($this->img_r);
$this->img_h = imagesy($this->img_r);
}
function resize($largestSide = 100) {
$width = imagesx($this->img_r);
$height = imagesy($this->img_r);
$newWidth = 0;
$newHeight = 0;
if($width > $height){
$newWidth = $largestSide;
$newHeight = $height * ($newWidth / $width);
}else{
$newHeight = $largestSide;
$newWidth = $width * ($newHeight / $height);
}
$this->dst_r = ImageCreateTrueColor($newWidth, $newHeight);
imagecopyresampled($this->dst_r, $this->img_r, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
$this->img_r = $this->dst_r;
$this->img_h = $newHeight;
$this->img_w = $newWidth;
}
function createFile($output_filename = null) {
if($this->ext == "JPG" OR $this->ext == "JPEG") {
imageJPEG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext, $this->quality);
} elseif($this->ext == "PNG") {
imagePNG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
} elseif($this->ext == "GIF") {
imageGIF($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext);
}
$this->output = $this->uploaddir.$output_filename.'.'.$this->ext;
}
function setUploadDir($dirname) {
$this->uploaddir = $dirname;
}
function flush() {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
imagedestroy($this->dst_r);
unlink($targetFile);
imagedestroy($this->img_r);
}
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file ($tempFile, $targetFile);
$image = new Image();
$image->setFile($targetFile);
$image->setUploadDir($targetPath);
$image->resize(800);
$image->createFile(md5($tempFile));
$image->flush();
}