Hello everyone, it's been a while since I've been on because everything has been going good with my site, until today. I've been working on my upload page, and am getting an error, here is the story behind it. I am creating a mp3 uploader where people can upload songs to my site. Once the songs have been chosen by the person, they are first checked for size, multiple extensions, correct extension, and whether the entry was empty or not. If there are no errors, the song will then uploaded to the temp directory for later processing. Here is where the problem comes in. I setup up debugging codes at every step of the error check process to display any info about error processing problems. The one problem is, everytime $errorempty on loop 1 $r=1 always gets echoed back to the screen even though the slot isn't empty. It then displays the or die statement from my move_uploaded_file statement saying "cannot move uploaded file to working directory", but when I go through my site, and check the temp folder that the uploads get moved to, all 4 temp files are in there. Is my upload code inadvertently sending another "blank" array $r number, supposedly "5" or "0", that is being processed, but since the loop only goes to 4 it can't process it, or is there an error in my coding? I have used basically the same code for all my other upload scripts and I have never gotten an or die statement. here is the code for the page:
session_start();
$workdir ="temp";
$destdir = "test/images/";
$numtracks = $_SESSION['numtracks'];
if (!isset($_COOKIE['commence'])){
$limit_size="10000000";
$r = 1;
if (4 >= $numtracks){
$q = $numtracks;
}
if (4 < $numtracks){
$q = 4;
}
while ($r <= $q){
$songname[$r] = $_FILES['upload']['name'][$r];
$check_imagename[$r] = explode(".", $songname[$r]);
$verify_imagename[$r] = count($check_imagename[$r]);
$extimagename[$r] = @strrchr($songname[$r], ".");
$tmpName[$r] = basename($_FILES['upload']['tmp_name'][$r]);
$file_size[$r] = $_FILES['upload']['size'][$r];
$tmpdelete[$r] = $workdir . "/" . $tmpName[$r];
if ($verify_imagename[$r] > "2"){
$_SESSION['errorsongname'] = "Yes";
echo "error more than 2".$r;
$errorsongname = true;
}
if ($errorsongname !==true){
if($file_size[$r] > $limit_size) {
$_SESSION['errorsize'] = "Yes";
echo"errorsize".$r;
$errorsize = true;
}
}
if ($errorsongname !==true and $errorsize !==true){
if ($file_size[$r] == ""){
$_SESSION['errorempty'] ="Yes";
echo"errorempty".$r;
$errorempty = true;
}
}
if ($errorsongname !==true and $errorsize !==true and $errorempty !==true ){
if ($extimagename[$r] !== ".mp3"){
$_SESSION['errorextension'] = "Yes";
echo"errornomp3".$r;
$errorsong = true;
}
}
move_uploaded_file($_FILES['upload']['tmp_name'][$r], $workdir."/".$tmpName[$r]) or die("Cannot move uploaded file to working directory");
$_SESSION['songs'][$r] = $songname[$r];
$_SESSION['filesize'][$r] = $file_size[$r];
$r++;
}
}