Posted: 12/14/2005 12:10:08 AM
I would like the user to be able to upload his or her image, just like they can upload an avatar.
I am trying to create a form to upload the image and add a new case to frontaction.php to handle the storing. This is where I am hung up of course.
I will be using the images to give my users a complete profile and it is working really good so far:
http://allpilots.com//index.php?env=-33:m20-1-1-1-s:l0-0-1-:n0-0-0:bb1-0-1-1-1-0-1&UserId=1
I uploaded the current picture through the admin panel
I am trying to copy the code used in the avatar case. Any ideas of what I need to change? I know this code will not work but I can't follow it well enough to modify it:
The new case in frontaction.php ---
case "m_userimage":
             if(is_array($_FILES))
             {
                foreach($_FILES as $field => $file)
                {
                   $allowed = TRUE;
                   if(strlen($_POST["imagetypes"
[$field]))
                   {
                     $types = explode(",",strtolower($_POST["imagetypes"
[$field]));
                     if(is_array($types))
                     {
                       if(count($types)>0)
                       {
                          $path_parts = pathinfo($file["name"
);
                          $ext = $path_parts["extension"
;
                          $allowed = in_array($ext,$types);
                          if(!$allowed)
                          {
                            $MissingCount++;
                            $FormError["m_userimage"
[$field] = "error one";
                          }
                        }
                     }
                   }
                   $maxsize = 
int)$_POST["maxsize"
[$field];
                   if($maxsize>0 && $allowed && $file["size"
>$maxsize)
                   {
                     $allowed = FALSE;
                     $MissingCount++;
                     $FormError["m_userimage"
[$field] = "error two";
                   }
                }
             } else { $FormError["m_userimage"
[$field] = "error three";
}
foreach($_FILES as $field => $file)
                   {
                     if($file["size"
>0)
                     {
                       $imgname = $_POST["imagename"
[$field];
                       $thumb = $_POST["isthumb"
[$field];
                       $IsDefault = 
int)$_POST["imgdefault"
[$field];
                       if($thumb)
                       {
                         $LocalThumb=1;
                       }
                       else
                         $LocalImage=1;
                       $img = $objImageList->GetImageByName($LinkResourceId,$imgname);
                       if(!is_object($img))
                       {
                         $img =& $objImageList->Add($imgname, "", $LinkResourceId,
                                                    $LocalImage, $LocalThumb,
                                                    "", "", 1, 0, $IsDefault, 0,0);
                       }
                       if($thumb)
                       {
                          $img->Set("LocalThumb",1);
                          $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb);
                          $img->Set("ThumbPath",$url);
                       }
                       else
                       {
                          $img->Set("LocalImage",1);
                          $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb);
                          $img->Set("LocalPath",$url);
                       }
                       $img->Update();
                     }
                   }
break;
[Edited By lhornaday on 12/14/05 12:10:56 AM]

				