hello,
je poste le code ici:
<?php
session_start();
if (isset($_SESSION['level']) && $_SESSION['level'] == 2){}
else
{
$_SESSION['error'] = "3";
header('Location: ../../errors/error.php');
}
require("../../includes/config.php");
require('../../includes/functions.tpl.php');
//initiate the array in which the files names will be stored
$i = 0;
$name_array = array();
$thumb_array = array();
while(list($key,$value) = each($_FILES['image']['name']))
{
if(!empty($value))
{
//$filename = $value;
//echo $_FILES['image']['name'][$key];
//print "<br>$filename<br>";
$uploaddir = "../../gifts";
$allowed_ext = array( 'jpg', 'gif', 'png' );
$max_size = "50000";
$max_height = "300";
$max_width = "300";
$upload = '';
//get the file's extension
$ext = pathinfo($_FILES['image']['name'][$key]);
$extension = $ext['extension'];
//compare uploaded file with authorized extensions
if (in_array($extension,$allowed_ext))
{
//check the file's size in kb
if($_FILES[image][size][$key] > $max_size)
{
echo 'File '.$key.' size is too big!;
$upload = false;
}
//check the file's dimension WxH
if ($max_width && $max_height)
{
list($width, $height, $type, $w) = getimagesize($_FILES['image']['tmp_name'][$key]);
if($width > $max_width || $height > $max_height)
{
echo '<br>File '.$key.' height and/or width are too big!';
$upload = false;
}
//upload the file!
else
{
//echo $_FILES['image']['tmp_name'][$key];
if(empty($upload) && is_uploaded_file($_FILES['image']['tmp_name'][$key]))
{
//create a random name for the uploaded file
$date = date ("Ymd");
$name = random_string();
$uploadname = $date.'_'.$name.'.'.$extension;
$name_array[] = "$uploadname";
move_uploaded_file($_FILES['image']['tmp_name'][$key],$uploaddir.'/'.$uploadname);
$i++;
$upload = true;
}
}
}
}
else
{
print "Incorrect file extension!";
}
}
}
if ($upload = true)
{
//insert fom values into database
$fields = array_keys($_POST);
for ($i = 0; $i < count($fields); $i++)
{
$array = array($_POST[$fields[2]], $_POST[$fields[1]], $_POST[$fields[0]]);
$start = implode("-", $array);
$array = array($_POST[$fields[5]], $_POST[$fields[4]], $_POST[$fields[3]]);
$expiry = implode("-", $array);
$name = addslashes($_POST[$fields[6]]);
$description = addslashes($_POST[$fields[7]]);
$stock = $_POST[$fields[8]];
$points_redeem = $_POST[$fields[9]];
$points_play = $_POST[$fields[10]];
$type = $_POST[$fields[11]];
$link = $_POST[$fields[12]];
$advertiser = $_POST[$fields[13]];
}
$query= ("INSERT INTO gifts (start, expiry, name, description, stock, points_redeem, points_play, type, link, pic1, pic2, pic3, pic4, pic5, pic6, thumb1, thumb2, thumb3, thumb4, thumb5, thumb6, id_advertiser)
VALUES ('$start', '$expiry', '$name', '$description', '$stock', '$points_redeem', '$points_play', '$type', '$link', 'gifts/$name_array[0]', 'gifts/$name_array[1]', 'gifts/$name_array[2]', 'gifts/$name_array[3]', 'gifts/$name_array[4]', 'gifts/$name_array[5]', 'gifts/thumbs/$name_array[0]', 'gifts/thumbs/$name_array[1]', 'gifts/thumbs/$name_array[2]', 'gifts/thumbs/$name_array[3]', 'gifts/thumbs/$name_array[4]', 'gifts/thumbs/$name_array[5]', '$advertiser' )");
mysql_query($query) or die('Invalid query: ' . mysql_error());
//create thumbs: normal size, thumbnail folder, size in pixels
createThumbs("../../gifts/","../../gifts/thumbs/",150);
echo 'Your file has been uploaded successfully! Yay!';
}
else
{
echo '<br>failed uploading the file';
}
?>
desole, c'est un peu indigeste...
mais je ne comprends pas pourquoi mes images redimensionnees ne sont pas telechargeables par ftp... (les thumbnails oui par contre...)
niveau: pas terrible en php mais je me soigne...