This is a very simple script, but it breaks when the slots is exactly 2, for other cases the script runs fine
i cant find the error, plz help !function main()
{
$slots=$_POST['counter']; //number of slots
include 'config.php';
for ($num = 1; $num <= $slots; $num++) //$num starts from 1, not 0
{
if (($_FILES["myfile$num"]['type']=='image/jpeg'))
{
move_uploaded_file($_FILES["myfile$num"]['tmp_name'],$albumDir.'\\'.$_FILES["myfile$num"]['name']);
copy($albumDir.'\\'.$_FILES["myfile$num"]['name'], $albumDir.'_thumb\\'.$_FILES["myfile$num"]['name']);
resize($_FILES["myfile$num"]['name']);
}
else if($_FILES["myfile$num"]['name']!='')
echo 'Image should be in JPEG/JPG format, and 开发者_如何学Csize should not exceed 1 MB';
}
}
check whether $_POST['counter'] value set ==2;then u proccedd...
$slots=count($_POST['name']);
//number of slots
include 'config.php';
for ($num = 1; $num <= $slots; $num++) //$num starts from 1, not 0
or
for ($num = 1; $num < $slots+1; $num++)
{
//your code..
}
Your code is fine. The following things could be happening:
Your counter var is different than the real number of uploaded files
Your filenames arenot exactly the ones you're trying to read.
Hope this helps. Cheers
start $num from 0
for ($num = 0; $num <= $slots; $num++)
精彩评论