par choubix » 14 nov. 2007, 11:58
par Ryle » 14 nov. 2007, 10:05
$tabNomFichier = array(); while (...) { // ... $tabNomFichier[] = $uploadname; // ... }
par Invité » 13 nov. 2007, 21:31
par Invité » 13 nov. 2007, 21:27
par Invité » 13 nov. 2007, 21:03
par Ryle » 13 nov. 2007, 19:59
par choubix » 13 nov. 2007, 18:44
par choubix » 13 nov. 2007, 15:13
par Ryle » 13 nov. 2007, 15:06
par choubix » 13 nov. 2007, 14:59
par Invité » 13 nov. 2007, 14:55
par h0_noMan » 13 nov. 2007, 14:29
par Invité » 13 nov. 2007, 14:18
printf("<pre>%s</pre>\n", print_r($_FILES, 1));
Array ( [image] => Array ( [name] => Array ( [0] => Active.jpg [1] => [2] => [3] => [4] => [5] => ) [type] => Array ( [0] => image/jpeg [1] => [2] => [3] => [4] => [5] => ) [tmp_name] => Array ( [0] => /tmp/php5710wx [1] => [2] => [3] => [4] => [5] => ) [error] => Array ( [0] => 0 [1] => 4 [2] => 4 [3] => 4 [4] => 4 [5] => 4 ) [size] => Array ( [0] => 15540 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) ) )
par Invité » 13 nov. 2007, 12:50
<?php session_start(); if (isset($_SESSION['level']) && $_SESSION['level'] == 2) { } else { $_SESSION['error'] = "3"; header('Location: ../../error.php'); } require("../../includes/config.php"); require('../../includes/functions.tpl.php'); while(list($key,$value) = each($_FILES['image']['name'])) { if(!empty($value)) { $filename = $value; //echo $_FILES[image][name][$key]; equivalent to print "$filename<br>"; $uploaddir = "../../gifts"; $allowed_ext = array( 'jpg', 'gif', 'jpeg', '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) { print "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) { print "<br>File '$key' height and/or width are too big!"; $upload = false; } //upload the file! else { 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; print "$uploaddir/$uploadname<br>"; move_uploaded_file($_FILES['image']['tmp_name'][$key],$uploaddir/$uploadname); } } } } } } ?>
par Ryle » 13 nov. 2007, 11:20
je souhaiterais un _ plutot qu'un - dans le nom du fichier.
$uploadname = $date . '_' . $name . '.' . $extension;
$_FILES['image']['size'][$key] // et pas $_FILES[image][size][$key]