Hi all. I'm having a problem uploading images with PHP - I've done it successfully before, but it's been a while. Now, the HTML form has the appropriate enctype and MAX_SIZE hidden field, everything runs correctly through the traps that I have set up, which leads me to believe that the application actually does think it's uploading the image. Problem is that it's just not uploading the image. The code is as follows....
$func=addTeam($_POST, $HTTP_POST_FILES['img']);
if($func){
print("didn't work");
}else{
print("worked");
}
function addTeam($infoArr, $fileArr){
if($infoArr['tuition'] == ""){
$tuition=0.00;
}else{
$tuition=$infoArr['tuition'];
}
if(uploadImage($fileArr, "teams")){
$qry="INSERT INTO tblteams (name, category, img, level, tuition) VALUES (\"".addslashes($infoArr['tName'])."\", \"".$infoArr['cat']."\", \"".$fileArr['name']."\", \"".addslashes($infoArr['lvl'])."\", $tuition);";
$rs=mysql_query($qry);
$id=mysql_insert_id();
if(!$rs){
$retVar = false;
}else{
$retVar = addRoster($infoArr, $id);
}
}
return($retVar);
}
//upload photos....
function uploadImage($fileArr, $fileDest){
$fileDir = "../images/".$fileDest;
if($fileArr['name']!=""){
if(is_uploaded_file($fileArr['tmp_name'])){
// if(($fileArr['type'] == "image/gif") || ($fileArr['type'] == "image/jpeg")){
if(getimagesize($fileArr['tmp_name'])){
if(move_uploaded_file($fileArr['tmp_name'], "$fileDir".$fileArr['name'])){
$retVar=true;
}else{
$retVar=false;
}
}else{
$retVar=false;
}
}else{
$retVar=false;
}
}else{
$retVar=false;
}
return($retVar);
}
I may have gotten myself confused with all the error checking, but I don't think that I have - everything seems to run fine. The "images/teams/" directory is chmod777, so that's not the problem. And the record inserts itself properly into the database, which should only happen if the file is successfully moved from the temporary directory to the permanent. And yet there's no file. Anyone have any ideas on what I'm missing here? I've looked through the manual, Sam's Teach Yourself PHP in 24 hours, Core PHP Programming, and past code that did work on the same server, and yet I can't find the fault. I've got more books that I could look through, but I'm in the process of moving and I'm not sure in which box they're packed.