SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple Uploading Files

    Hi Guys,

    i'm having problems uploading 5 photos at the 1 time with my script, it only uploads 1 photos and stores the same filename into mysql 5 times i can't figure this out been at if for ages:

    PHP Code:
         ## the gets ########################################################################
         
    if($_GET['page'] == "upload_headshots" ) {
         
         
    ## isset ###########################################################################
         
    if(isset($_POST['submit'])) {
         
         
    ## variables #######################################################################
         
    $headshot1 $_FILES['headshot1']['name'];
         
    $headshot2 $_FILES['headshot2']['name'];
         
    $headshot3 $_FILES['headshot3']['name'];
         
    $headshot4 $_FILES['headshot4']['name'];
         
    $headshot5 $_FILES['headshot5']['name'];
         
         
    ## max size ########################################################################
         
    $max_image_size 512000;
         
         
    ## allowed types ###################################################################
         
    $allowed = array("image/gif","image/jpg","image/x-png","image/jpeg","image/pjpeg","image/bmp");
         
         
    ## max width and height ############################################################
         
    $max_image_width 500;
         
    $max_image_height 450;
         
         
    ## random number ###################################################################
         
    $random_number rand(00000000,99999999);
         
         
    ## the renamed photos ##############################################################
         
    $renamed_photo_1 $random_number.".".substr($_FILES["headshot1"]["name"],strtolower(strlen($_FILES["headshot1"]["name"]))-3,3);
         
    $renamed_photo_2 $random_number.".".substr($_FILES["headshot2"]["name"],strtolower(strlen($_FILES["headshot2"]["name"]))-3,3);
         
    $renamed_photo_3 $random_number.".".substr($_FILES["headshot3"]["name"],strtolower(strlen($_FILES["headshot3"]["name"]))-3,3);
         
    $renamed_photo_4 $random_number.".".substr($_FILES["headshot4"]["name"],strtolower(strlen($_FILES["headshot4"]["name"]))-3,3);
         
    $renamed_photo_5 $random_number.".".substr($_FILES["headshot5"]["name"],strtolower(strlen($_FILES["headshot5"]["name"]))-3,3);
         
         
    ## validation 1 ####################################################################
         
    if ($_FILES["headshot1"]["size"] > $max_image_size) {
         
            echo 
    '<br /><font color="red">Error:</font> Sorry, 1 Or More Headshots Are To Big Please (<a href="javascript: history.go(-1)">Go Back</a>) Choose Another.<br /><br />';
            include(
    "includes/footer.php");
            exit;     
         
         }
         
         
    ## validation 2 ####################################################################
         
    $dim getimagesize($_FILES["headshot1"]["tmp_name"]);

         if(
    $dim[0] >= $max_image_width || $dim[1] >= $max_image_height) {
      
            echo 
    "<p>Sorry, The Maximum Width Is: 540 And The Maximum Height Is: 400 Please <a href=\"java script: history.go(-1)\">Go Back</a> And Fix This.</p>";
            include(
    "includes/footer.php");
            exit;
        
         } 
         
         
    ## validation 3 ####################################################################
         
    if (!in_array($_FILES["headshot1"]["type"], $allowed)) {
       
             echo 
    "Not a valid file type.";
             include(
    "includes/footer.php");
             exit;
        
          }
          
          
    ## query for a previous photo #####################################################
          //$previous_photo_query = "SELECT * FROM `users` WHERE `username`='$member'";
          //$previous_photo_result = mysql_query($previous_photo_query) or die (mysql_error());
          //$rows = mysql_fetch_object($previous_photo_result);
          //$photo_to_delete_1 = $rows->headshot_1;
          //$photo_to_delete_2 = $rows->headshot_2;
          //$photo_to_delete_3 = $rows->headshot_3;
          //$photo_to_delete_4 = $rows->headshot_4;
          //$photo_to_delete_5 = $rows->headshot_5;
          
          ## delete previous photos #########################################################
          
    unlink("uploaded_headshots/".$photo_to_delete_1);
          
    unlink("uploaded_headshots/".$photo_to_delete_2);
          
    unlink("uploaded_headshots/".$photo_to_delete_3);
          
    unlink("uploaded_headshots/".$photo_to_delete_4);
          
    unlink("uploaded_headshots/".$photo_to_delete_5);
          
          
    ## upload path ####################################################################
          
    $uploadpath "uploaded_headshots/";
          
    $uploadpath $uploadpath.$renamed_photo_1;
          
    $uploadpath "uploaded_headshots/";
          
    $uploadpath $uploadpath.$renamed_photo_2;
          
    $uploadpath "uploaded_headshots/";
          
    $uploadpath $uploadpath.$renamed_photo_3;
          
    $uploadpath "uploaded_headshots/";
          
    $uploadpath $uploadpath.$renamed_photo_4;
          
    $uploadpath "uploaded_headshots/";
          
    $uploadpath $uploadpath.$renamed_photo_5;
                
          
    ## move the uploaded files ########################################################  
          
    if (!move_uploaded_file($_FILES["headshot1"]["tmp_name"], $uploadpath)) {  
            
             echo 
    '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!
    move_uploaded_file($_FILES["headshot2"]["tmp_name"], $uploadpath)) {  
            
             echo 
    '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!
    move_uploaded_file($_FILES["headshot3"]["tmp_name"], $uploadpath)) {  
            
             echo 
    '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!
    move_uploaded_file($_FILES["headshot4"]["tmp_name"], $uploadpath)) {  
            
             echo 
    '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!
    move_uploaded_file($_FILES["headshot5"]["tmp_name"], $uploadpath)) {  
            
             echo 
    '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }  
          
          
    ## store into mysql ###############################################################
          
    $upload_query "UPDATE `users` SET `headshot_1`='$renamed_photo_1',`headshot_2`='$renamed_photo_2',`headshot_3`='$renamed_photo_3',`headshot_4`='$renamed_photo_4',`headshot_5`='$renamed_photo_5' WHERE `username`='$member'";
          
    $upload_result mysql_query($upload_query) or die (mysql_error());
          
          
    ## upload a success ###############################################################
          
    if($upload_result) {
          
             echo 
    '<br />Headshots Have Been Uploaded Successfully.<br /><br />';
             include(
    "includes/footer.php");
             exit;
          
          }
         
         
         } else {
          
    ## isset ###########################################################################
          
          
    $query_headshots "SELECT * FROM `users` WHERE `username`='$member'";
          
    $result_headshots mysql_query($query_headshots) or die (mysql_error());
          
    $row mysql_fetch_array($result_headshots) or die (mysql_error());
          
    $head1 $row['headshot_1'];
          
    $head2 $row['headshot_2'];
          
    $head3 $row['headshot_3'];
          
    $head4 $row['headshot_4'];
          
    $head5 $row['headshot_5'];
         
         echo 
    '<table width="300" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0" />
               <form action="'
    .$_SERVER['PHP_SELF'].'?page=upload_headshots" method="POST" enctype="multipart/form-data">
               <th colspan="2" align="center" bgcolor="#8f0002"><img src="images/upload_headshots.gif" /></th>
               </tr>
               <tr>
               <td align="center">Upload Headshot 1:</td><td align="left"><input type="file" name="headshot1" size="30"></td>
               </tr>
               <tr>
               <td align="center">Upload Headshot 2:</td><td align="left"><input type="file" name="headshot2" size="30"></td>
               </tr>
               <tr>
               <td align="center">Upload Headshot 3:</td><td align="left"><input type="file" name="headshot3" size="30"></td>
               </tr>
               <tr>
               <td align="center">Upload Headshot 4:</td><td align="left"><input type="file" name="headshot4" size="30"></td>
               </tr>
               <tr>
               <td align="center">Upload Headshot 5:</td><td align="left"><input type="file" name="headshot5" size="30"></td>
               <tr>
               <td colspan="2" bgcolor="#8f0002" align="right" /><input class="button" type="submit" name="submit" value="Upload Headshots >>>" /></td>
               </tr>
               </table></form><br />'
    ;
               
         echo 
    '<table width="300" border="1" bordercolor="#000000" cellpadding="3" cellspacing="0" />
               <th align="center" bgcolor="#8f0002"><font color="#ffffff" />Uploaded Headshots</font></th>
               </tr>
               <tr>
               <td align="center">'
    ;
               
               
    ## empty headshots ###########################################################
               
    if(empty($head1)) {
               
                  echo 
    '<img src="images/no_headshot.gif" />';
               
               } else {
               
                  echo 
    '<img src="uploaded_headshots/'.$head1.'" />';
               
               }
               
         echo 
    '</td>
               </tr>
               <tr>
               <td align="center">'
    ;          
               if(empty(
    $head2)) {
               
                  echo 
    '<img src="images/no_headshot.gif" />';
               
               } else {
               
                  echo 
    '<img src="uploaded_headshots/'.$head2.'" />';
               
               }
        echo 
    ' </td>
               </tr>
               <tr>
               <td align="center">'
    ;
               if(empty(
    $head3)) {
               
                  echo 
    '<img src="images/no_headshot.gif" />';
               
               } else {
               
                  echo 
    '<img src="uploaded_headshots/'.$head3.'" />';
               
               }           
        echo 
    ' </tr>
               <tr>
               <td align="center">'
    ;
               if(empty(
    $head4)) {
               
                  echo 
    '<img src="images/no_headshot.gif" />';
               
               } else {
               
                  echo 
    '<img src="uploaded_headshots/'.$head4.'" />';
               
               }  
        echo 
    ' </tr>
               <tr>
               <td align="center">'
    ;
               if(empty(
    $head5)) {
               
                  echo 
    '<img src="images/no_headshot.gif" />';
               
               } else {
               
                  echo 
    '<img src="uploaded_headshots/'.$head5.'" />';
               
               }  
        echo 
    ' </tr>
               </table><br />'
    ;
               
            include(
    "includes/footer.php");
            exit;
            
          } 
    # end isset #####################################################################
         
         
    }
         
    ## the gets ######################################################################## 
    can anyone see the problem at all?

    thanks guys

    Graham

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ## random number ###################################################################
    $random_number rand(00000000,99999999);

    ## the renamed photos ##############################################################
    $renamed_photo_1 $random_number.".".substr($_FILES["headshot1"]["name"],strtolower(strlen($_FILES["headshot1"]["name"]))-3,3);
    $renamed_photo_2 $random_number.".".substr($_FILES["headshot2"]["name"],strtolower(strlen($_FILES["headshot2"]["name"]))-3,3);
    $renamed_photo_3 $random_number.".".substr($_FILES["headshot3"]["name"],strtolower(strlen($_FILES["headshot3"]["name"]))-3,3);
    $renamed_photo_4 $random_number.".".substr($_FILES["headshot4"]["name"],strtolower(strlen($_FILES["headshot4"]["name"]))-3,3);
    $renamed_photo_5 $random_number.".".substr($_FILES["headshot5"]["name"],strtolower(strlen($_FILES["headshot5"]["name"]))-3,3); 
    since you only set $random_number once, that's what it's using for each image.
    PHP Code:
    // change
    $renamed_photo_1 $random_number.".".substr($_FILES["headshot1"]["name"],strtolower(strlen($_FILES["headshot1"]["name"]))-3,3);
    // to
    $renamed_photo_1 rand(0000000099999999).".".strtolower(substr($_FILES['headshot1']['name'], -3)); // you don't need all that extra code.
    // and so on. 
    Also, you might try using pathinfo() on the uploaded files instead of substr() 'cause what if IMG.jpeg is uploaded, not IMG.jpg... I have something similar to this setup, so I'll show you my code:
    PHP Code:
    if (isset($_FILES['upload'])) {
        
    $upload = array();
        for (
    $i 0$i $_GET['files']; $i++) {
            
    $info pathinfo($_FILES['upload']['name'][$i]);
            
    $upload[] = array("new" => md5($_FILES['upload']['name'][$i]).".".$info['extension'],
                               
    "tmp" => $_FILES['upload']['tmp_name'][$i],
                              
    "size" => $_FILES['upload']['size'][$i]);
        }
        
    $path "/var/www/nathan/phpdocs/";
        foreach (
    $upload as $file) {
            if (!
    copy($file['tmp'], $path.$file['new'])) {
                echo 
    "Error uploading ".$file['tmp']." to ".$path.$file['new'].".";
            }
        }
    } else {
        echo 
    "<form action=\"test_upload.php?files=5\"  method=\"post\" enctype=\"multipart/form-data\">\n";
        echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        echo 
    "<input type=\"submit\">\n";

    Last edited by notepad_coder; Jun 20, 2007 at 13:19.
    - the lid is off the maple syrup again!

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi NC,

    thanks for the tips mate i have ammended the code:

    PHP Code:
         $max_image_size 512000;
         
         
    ## allowed types ###################################################################
         
    $allowed = array("image/gif","image/jpg","image/x-png","image/jpeg","image/pjpeg","image/bmp");
         
         
    ## max width and height ############################################################
         
    $max_image_width 500;
         
    $max_image_height 450;
         
         
    ## random number ###################################################################
         
    $random_number rand(00000000,99999999);
         
         
    ## the renamed photos ##############################################################
         
    $renamed_photo_1 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot1']['name'], -3));
         
    $renamed_photo_2 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot2']['name'], -3));
         
    $renamed_photo_3 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot3']['name'], -3));
         
    $renamed_photo_4 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot4']['name'], -3));
         
    $renamed_photo_5 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot5']['name'], -3));
         
         
    ## validation 1 ####################################################################
         
    if ($_FILES["headshot1"]["size"] > $max_image_size) {
         
            echo 
    '<br /><font color="red">Error:</font> Sorry, 1 Or More Headshots Are To Big Please (<a href="javascript: history.go(-1)">Go Back</a>) Choose Another.<br /><br />';
            include(
    "includes/footer.php");
            exit;     
         
         }
         
         
    ## validation 2 ####################################################################
         
    $dim getimagesize($_FILES["headshot1"]["tmp_name"]);

         if(
    $dim[0] >= $max_image_width || $dim[1] >= $max_image_height) {
      
            echo 
    "<p>Sorry, The Maximum Width Is: 540 And The Maximum Height Is: 400 Please (<a href=\"javascript: history.go(-1)\">Go Back</a>) And Fix This.</p>";
            include(
    "includes/footer.php");
            exit;
        
         } 
         
         
    ## validation 3 ####################################################################
         
    if (!in_array($_FILES["headshot1"]["type"], $allowed)) {
       
             echo 
    "<br /><font color=\"red\">Error:</font> Sorry, That File Is Not Allowed Please (<a href=\"javascript: history.go(-1)\">Go Back</a>) And Check It Again.<br /><br />";
             include(
    "includes/footer.php");
             exit;
        
          }
          
          
    ## query for a previous photo #####################################################
          //$previous_photo_query = "SELECT * FROM `users` WHERE `username`='$member'";
          //$previous_photo_result = mysql_query($previous_photo_query) or die (mysql_error());
          //$rows = mysql_fetch_object($previous_photo_result);
          //$photo_to_delete_1 = $rows->headshot_1;
          //$photo_to_delete_2 = $rows->headshot_2;
          //$photo_to_delete_3 = $rows->headshot_3;
          //$photo_to_delete_4 = $rows->headshot_4;
          //$photo_to_delete_5 = $rows->headshot_5;
          
          ## delete previous photos #########################################################
          
    unlink("uploaded_headshots/".$photo_to_delete_1);
          
    unlink("uploaded_headshots/".$photo_to_delete_2);
          
    unlink("uploaded_headshots/".$photo_to_delete_3);
          
    unlink("uploaded_headshots/".$photo_to_delete_4);
          
    unlink("uploaded_headshots/".$photo_to_delete_5);
          
          
    ## upload path ####################################################################
          /*$uploadpath = "uploaded_headshots/";
          $uploadpath = $uploadpath.$renamed_photo_1;
          $uploadpath = "uploaded_headshots/";
          $uploadpath = $uploadpath.$renamed_photo_2;
          $uploadpath = "uploaded_headshots/";
          $uploadpath = $uploadpath.$renamed_photo_3;
          $uploadpath = "uploaded_headshots/";
          $uploadpath = $uploadpath.$renamed_photo_4;
          $uploadpath = "uploaded_headshots/";
          $uploadpath = $uploadpath.$renamed_photo_5;*/
                
          ## move the uploaded files ########################################################  
          /*if (!move_uploaded_file($_FILES["headshot1"]["tmp_name"], $uploadpath)) {  
            
             echo '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!move_uploaded_file($_FILES["headshot2"]["tmp_name"], $uploadpath)) {  
            
             echo '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!move_uploaded_file($_FILES["headshot3"]["tmp_name"], $uploadpath)) {  
            
             echo '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!move_uploaded_file($_FILES["headshot4"]["tmp_name"], $uploadpath)) {  
            
             echo '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }else if (!move_uploaded_file($_FILES["headshot5"]["tmp_name"], $uploadpath)) {  
            
             echo '<br /><font color="red">Error:</font> Sorry, An Error Has Occured Please (<a href="javascript: history.go(-1)">Go Back</a>) And Try Again.<br /><br />';  
            
          }*/
          
          
    $upload = array();
          foreach (
    $_FILES['upload'] as $file) {
              
    $info pathinfo($file['name']);
                  
    $upload[] = array("new" => md5($file['name']).".".$info['extension'],                            
                  
    "tmp" => $file['tmp_name']);
          }
                  
          
    $path "uploaded_headshots/";
          foreach (
    $upload as $file) {
              if (!
    copy($file['tmp'], $path.$file['new'])) { 
                     echo 
    "There was an error uploaded ".$file['tmp']." to ".$path.$file['new'].".";
           }
           
          } 
          
          
    ## store into mysql ###############################################################
          
    $upload_query "UPDATE `users` SET `headshot_1`='$renamed_photo_1',`headshot_2`='$renamed_photo_2',`headshot_3`='$renamed_photo_3',`headshot_4`='$renamed_photo_4',`headshot_5`='$renamed_photo_5' WHERE `username`='$member'";
          
    $upload_result mysql_query($upload_query) or die (mysql_error());
          
          
    ## upload a success ###############################################################
          
    if($upload_result) {
          
             echo 
    '<br />Headshots Have Been Uploaded Successfully.<br /><br />';
             include(
    "includes/footer.php");
             exit;
          
          } 
    only some of it, i have commented out the other code does this look right to you? it now stores 5 different random numbers in mysql but it doesn't seem to be moving them any ideas on what could be up?

    thanks mate

    Graham

  4. #4
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for one:
    PHP Code:
    // this doesn't work.
    $renamed_photo_1 rand(0000000099999999).".".strtolower(pathinfo($_FILES['headshot1']['name'], -3));

    // Do something like this
    $photo_1_info pathinfo($_FILES['headshot1']['name']);
    $renamed_photo_1 rand(0000000099999999).".".$photo_1_info['extension']; 
    And now for the uploading:
    PHP Code:
    // this is if $_FILES['upload'] is an array of FILE inputs
          
    $upload = array();
          foreach (
    $_FILES['upload'] as $file) {
              
    $info pathinfo($file['name']);
                  
    $upload[] = array("new" => md5($file['name']).".".$info['extension'],                            
                  
    "tmp" => $file['tmp_name']);
          }
                  
          
    $path "uploaded_headshots/";
          foreach (
    $upload as $file) {
              if (!
    copy($file['tmp'], $path.$file['new'])) { 
                     echo 
    "There was an error uploaded ".$file['tmp']." to ".$path.$file['new'].".";
           }
          
          } 

    // Do something like this instead:
    $path "/full/path/to/uploaded_headshots/";
    if (!
    copy($_FILES['headshot1']['tmp_name'], $path.$renamed_photo_1)) {
        echo 
    "Error uploading '".$renamed_photo_1.".'";
    }
    if (!
    copy($_FILES['headshot2']['tmp_name'], $path.$renamed_photo_2)) {
        echo 
    "Error uploading '".$renamed_photo_2.".'";
    }
    // And so on for each file
    // Do this for each FILE input field. 
    - the lid is off the maple syrup again!

  5. #5
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to take a look at this, it's doing pretty much the same thing:
    PHP Code:
    <?php
    if (isset($_FILES['upload'])) {
        
    $upload = array();
        
    $path "/full/path/to/uploaded_headshots/";
        for (
    $i 0$i $_GET['files']; $i++) {
            
    $info pathinfo($_FILES['upload']['name'][$i]);
            
    $upload[] = array("new" => sprintf("%'08s"mt_rand(099999999)).".".$info['extension'],
                              
    "tmp" => $_FILES['upload']['tmp_name'][$i],
                              
    "size" => $_FILES['upload']['size'][$i],
                              
    "type" => $_FILES['upload']['type'][$i]);
        }
        
    $allowed = array("image/gif""image/jpg""image/x-png""image/jpeg""image/pjpeg""image/bmp");
        
    $max_size 521000;
        
    $max_width 500;
        
    $max_height 450;
        
    $error 0;
        
    $i 1;
        foreach (
    $upload as $file) {
            if (
    in_array($file['type'], $allowed)) { // check if type allowed
                
    if ($file['size'] < $max_size) { // check file size
                    
    $size getimagesize($file['tmp']);
                    if ((
    $size[0] < $max_width) && ($size[1] < $max_height)) { // check image size
                        
    if (!copy($file['tmp'], $path.$file['new'])) {
                            echo 
    "Error uploading ".$file['tmp']." to ".$path.$file['new'].".";
                            die();
                        } else {
                            
    $img "headshot_".$i;
                            
    $result mysql_query("SELECT ".$img." FROM users WHERE username='".$member."'");
                            while (
    $row mysql_fetch_assoc($result)) {
                                
    unlink($path.$row[$img]);
                            }
                            
    mysql_query("UPDATE useres SET ".$img."='".$file['new']."' QHWEW username='".$member."'");
                            
    $error 0;
                        }
                    } else {
                        
    $error 1;
                    }
                } else {
                    
    $error 1;
                }
            } else {
                
    $error 1;
            }
            
    $i++;
        }
        if (
    $error == 1) {
            echo 
    "There was an error.";
        }
    } else {
        
    $files 5;
        echo 
    "<form action=\"".$_SERVER['PHP_SELF']."?files=".$files."\"  method=\"post\" enctype=\"multipart/form-data\">\n";
        for (
    $i 0$i $files$i++) {
            echo 
    "<input type=\"file\" name=\"upload[]\" /><br />\n";
        }
        echo 
    "<input type=\"submit\">\n";
    }
    ?>
    Last edited by notepad_coder; Jun 20, 2007 at 15:35.
    - the lid is off the maple syrup again!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •