hi all,
I was using a script to upload 1 image on my server.
I am now "upgrading" this script to be able to upload more than 1 pic at a time.
I am facing a problem now on this line (i think). when it comes to "writing" the pic on the server nothing happens...
move_uploaded_file($_FILES[image][tmp_name][$key],$uploaddir.'/'.$uploadname);
in the following code:
<?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 "$uploadname<br>";
move_uploaded_file($_FILES[image][tmp_name][$key],$uploaddir.'/'.$uploadname);
}
}
}
}
}
}
?>
can anybody help me with this please?
by the way, on this line :
$uploadname = "$date-$name.$extension";
how can i change the - for a _ ? thanks!