php script upload works while register global Off

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • studsir
    New Member
    • Jun 2012
    • 22

    #16
    Mr. Dormilich , I am very appreciated your help, but I really not enough aware about php language.
    all my script is one file which is inside the cod tags.
    there ara not much variables, so please look again and give me the correct page.

    Thank you very much

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #17
      post your script, then I can make comment on the issues I see.

      Comment

      • studsir
        New Member
        • Jun 2012
        • 22

        #18
        my upload script under a folder called upload
        inside that directory there is a file named index.php
        and a file named count.txt, and a folder called up

        now when I use the http://www.domain.com/upload/index.php

        I brows the iamge and when upload the url will be


        and the index.php has three input cells which I can manage to select three files and uploaded them at once.

        and the count.txt, only has the number of the visits and increase every page visit.

        here again the index.php as it is ( the original ) that works as register gloabl On, and not while it is Off


        Code:
        <?php 
        
        
        //  ************ you should change  ******************** 
        /*  The change only between the quotations */ 
        
        // Name of the site 
        $neme_sate = ""; 
        
        // The upload folder 
        $Dir = ""; 
        
        //the path of the upload script, and must end with "/" 
        $ULR = ""; 
        
        //  ************ Optional  ************************ 
        
        // authorization 
        $user1 = "1" ;  //if you want to to use it by a valid username put "1" 
        
        // the name of the user 
        $user = "test" ; 
        
        //maximun file size in kb 
        $size_end = "200"; 
        
        // specify the files 
        $exten = array (".jpg",".JPG"); 
        
        
        //  ***********  style modifications ****************** 
        //page backround 
        $body = "EDF3F3";  
        // table color borders 
        $color1 = "006F00";  
        // table color head 
        $color2 = "669999";  
        // table background color 
        $color3 = "E1ECEC"; 
        // font color head 
        $font_color1 = "E1ECEC"; 
        // font color content 
        $font_color2 = "000000 "; 
        
        
        //***************************************************** 
        // changing this, the uploader will not work 
        //***************************************************** 
        $exten1 = strrchr($file1_name ,'.'); 
        $exten2 = strrchr($file2_name ,'.'); 
        $exten3 = strrchr($file3_name ,'.'); 
        $size_round = round (($size_end * 1024) ,0); 
        $size1 = round(($file1_size / 1024),1) ; 
        $size2 = round(($file2_size / 1024),1) ; 
        $size3 = round(($file3_size / 1024),1) ; 
        $sizeall =$size1+ $size2+ $size3; 
        $fp = fopen ("count.txt", "r"); 
        $bytes = 7; 
        $buffer = fread($fp, $bytes); 
        fclose ($fp); 
        $fp2 = fopen ("count.txt", "w+"); 
        fwrite ($fp2, $buffer+1); 
        fclose ($fp2); 
        $Count=$buffer+1; 
        echo "<body background=../images/bricks.gif>"; 
        echo " 
          <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"  height=\"100%\">
             <tr><td width=\"100%\" valign=\"top\"> 
              <p align=\"center\" style=\"margin-bottom: 25\"> 
               <img border=\"0\" src=\"logo_med.gif\"> 
              </td</tr> 
              <tr><td width=\"100%\" valign=\"\"> 
              <p align=\"center\"><b> 
              "; 
           switch ($ar1ar) 
                { 
              default: 
             echo "<html>"; 
             echo "<title>$neme_sate</title>"; 
        echo "<CENTER> 
        <form method=\"POST\" action=\"$PHP_SELF?ar1ar=up\" enctype=\"multipart/form-data\">
         <div align=\"center\"> 
        <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\" bordercolor=\"$color1\" width=\"90%\">
         <tr><td width=\"100%\" background=\"../images/gradient_1.gif\" style=\"padding-right: 20\">
         <p style=\"margin-top: 0; margin-bottom: 0\"><font color=\"FFFF00\"><b>term of use</b></font></td>
         </tr> 
                <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                <p align=\"center\" style=\"margin-top: 3; margin-bottom: 3\"> 
                <font color=\"$font_color2\"> <b>The size of the image should be smaller than :  ( $size_end ) kb</b></font>
                 </td></tr> 
                 </table> 
                 <p align=\"center\" style=\"margin-top: 2; margin-bottom: 2\">&nbsp;</p> ";
                  if ($user1 == "1") 
                 { 
                 echo " 
               <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\"  bordercolor=\"$color1\" width=\"90%\">
               <tr> 
                <td width=\"100%\" bgcolor=\"FEF9DA\" style=\"padding-right: 20\"> 
                <p style=\"margin-top: 0; margin-bottom: 0\"><font color=\"$font_color1\"><b>login</b></font></td>
               </tr> 
                <tr><td width=\"100%\" bgcolor=\"$color3\"> 
                <p align=\"center\" style=\"margin-top: 5; margin-bottom: 5\"> 
                 <input type=text name=text1 size=50>  <font color=\"$font_color2\"><b>The username :&nbsp;</b></font>
               </td></tr> 
               </table> 
                  "; 
               } 
                 echo " 
                 <p align=\"center\" style=\"margin-top: 2; margin-bottom: 2\">&nbsp;</p>
                  <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\" bordercolor=\"$color1\" width=\"90%\">
               <tr> 
                <td width=\"100%\" background=\"../images/gradient_1.gif\" style=\"padding-right: 20\">
                 <p style=\"margin-top: 0; margin-bottom: 0\"><font color=\"FFFF00\"><b>upload images</b></font></td>
               </tr> 
              <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                <p align=\"center\" style=\"margin-top: 5; margin-bottom: 5\"> 
                 <input type=file name=file1 size=50><br> 
                 <input type=file name=file2 size=50><br> 
                 <input type=file name=file3 size=50><br> 
              </td></tr> 
              <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                <p align=\"center\" style=\"margin-top: 3; margin-bottom: 3\"> 
                <font color=\"000000\"><b> 
                <button name=\"submit\" type=\"submit\">upload</button> 
                <input type=\"reset\" value=\"reset\" name=\"B2\"> 
                </b></font> 
                </td></tr></table> 
                </form> 
                  "; 
                  echo "$Count : number of vistors<br>"; 
                 break; 
                case "up": 
                echo "<title>$neme_sate</title>"; 
                if (($user1=="1") && ($text1 <> "$user")) 
                { 
                  echo  " 
                 <div align=\"center\"> 
                 <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
                    <tr> 
                 <td width=\"100%\" bgcolor=\"$color2\" style=\"padding-right: 20\"> 
                 <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"$font_color1\"><b>error</b></font></td>
                   </tr> 
                  <tr><td width=\"100%\" bgcolor=\"$color3\">"; 
                  echo "<font color=\"$font_color2\"><b><br>wrong username<br><br></b></font>";
                   echo " </td></tr></table><br> "; 
                 } 
                 else{ 
                 if ($user1 == "1") 
               { 
                echo  " 
             <div align=\"center\"> 
             <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
                <tr> 
                 <td width=\"100%\" bgcolor=\"$color2\" style=\"padding-right: 20\"> 
                 <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"$font_color1\"><b>login username</b></font></td>
                </tr> 
             <tr><td width=\"100%\" bgcolor=\"$color3\"> "; 
               echo "<font color=\"$font_color2\">  welocome $text1 </font><br>"; 
               echo " </td></tr></table><br> "; 
               } 
             echo  " 
            <div align=\"center\"> 
             <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
         
                <tr> 
                 <td width=\"100%\" background=\"../images/gradient_1.gif\" style=\"padding-right: 20\">
                  <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"FFFF00\"><b>feild one information</b></font></td>
                 </tr> 
        
               <tr><td width=\"100%\" bgcolor=\"FEF9DA\">"; 
        
        
                 if ($file1_name == "") 
                    echo "<br><font color=\"$font_color2\">you did not input any image</font><br>";
         
                 elseif (file_exists("$Dir/$file1_name")) 
                    echo "<br><font color=\"$font_color2\">the name of the image is already found </font><br><br>";
         
                 elseif (!in_array( $exten1 , $exten)) 
                    echo "<br><font color=\"$font_color2\">the file extinsion is not allowed</font><br><br>";
         
                 elseif ($file1_size > "$size_round") 
                    echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size1 and the maximun file size is $size_end kb</font><br><br>";
         
                 else { 
                    @copy($file1, "$Dir/$file1_name"); 
                    echo"<font color=\"$font_color2\">The image is uploaded</font><br>";
                     echo"<font color=\"$font_color2\">The size of the image :  $size1 kb  </font><br>";
                     echo"<font color=\"$font_color2\">Image url : </font><br>"; 
                    echo"<a target=\"_blank\" href=\"$ULR$Dir/$file1_name\">$ULR$Dir/$file1_name</a><br><br>";
                       } 
                echo " </td></tr></table><br> "; 
               echo  " 
             <div align=\"center\"> 
             <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" id=\"AutoNumber1\"  width=\"90%\">
         
               <tr> 
                 <td width=\"100%\" background=\"../images/gradient_1.gif\" style=\"padding-right: 20\">
                  <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"FFFF00\"><b>feild two information</b></font></td>
                </tr> 
        
               <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> "; 
        
                 if ($file2_name == "") 
                    echo "<font color=\"$font_color2\"><br>you did not input any image<br></font>";
         
                 elseif (!in_array( $exten2 , $exten)) 
                    echo "<font color=\"$font_color2\"><br>the file extinsion is not allowed<br><br></font>";
         
                 elseif (file_exists("$Dir/$file2_name")) 
                    echo "<font color=\"$font_color2\"><br>the name of the image is already found <br><br></font>";
         
                 elseif ($file2_size > "$size_round") 
                    echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size2 and the maximun file size is $size_end kb</font><br><br>";
         
                 else { 
                    @copy($file2, "$Dir/$file2_name"); 
                    echo"<font color=\"$font_color2\">The image is uploaded<br></font>";
                     echo"<font color=\"$font_color2\">The size of the image :  $size2 kb <br></font>";
                     echo"<font color=\"$font_color2\"> Image url :</font><br>"; 
                    echo"<a target=\"_blank\" href=\"$ULR$Dir/$file2_name\">$ULR$Dir/$file2_name</a><br><br>";
         
                       } 
                 echo " </td></tr></table><br> "; 
        
              echo  " 
             <div align=\"center\"> 
             <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" id=\"AutoNumber1\"  width=\"90%\">
         
               <tr> 
                 <td width=\"100%\" background=\"../images/gradient_1.gif\" style=\"padding-right: 20\">
                  <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"FFFF00\"><b>feild three information</b></font></td>
                </tr> 
        
               <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> "; 
        
                 if ($file3_name == "") 
                    echo "<font color=\"$font_color2\"><br>you did not input any image<br></font>";
                  elseif (!in_array( $exten3 , $exten)) 
                    echo "<font color=\"$font_color2\"><br>the file extinsion is not allowed<br><br></font>";
                  elseif (file_exists("$Dir/$file3_name")) 
                    echo "<font color=\"$font_color2\"><br>the name of the image is already found <br><br></font>";
                 elseif ($file3_size > "$size_round") 
                    echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size3 and the maximun file size is $size_end kb</font><br><br>";
                   else { 
                    @copy($file3, "$Dir/$file3_name"); 
                    echo"<font color=\"$font_color2\"> The image is uploaded <br></font>";
                     echo"<font color=\"$font_color2\">The size of the image : $size3 kb <br></font>";
                     echo"<font color=\"$font_color2\"> Image url :</font><br>"; 
                    echo"<a target=\"_blank\" href=\"$ULR$Dir/$file3_name\">$ULR$Dir/$file3_name</a><br><br>";
                       }echo " </td></tr></table><br> ";} 
                       
                   echo"<a target=\"_self\" href=\"$PHP_SELF\">home page</a><br><br>"; 
                  echo "$Count : Number of visitors<br>"; 
                  break;} 
                 echo " 
                 </td></tr> 
                        </table> 
        ";?>

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #19
          yupp, that code won’t work with register_global s off. lines #49 - #51 & #53 - #55 all contain undefined variables. I can only guess what they mean, but I think you should find the info in the $_FILES superglobal.

          further undefined variables (or I didn’t find them):
          - $ar1ar
          - $text1
          - $size_round


          and again, the Manual has a section about uploading multiple files.

          Comment

          • studsir
            New Member
            • Jun 2012
            • 22

            #20
            $ar1ar
            you can find it here

            <form method=\"POST\" action=\"$PHP_S ELF?ar1ar=up\" enctype=\"multi part/form-data\">

            And when the upload finish another page will come wih results and in the address url will look like this



            $text1

            it is for login information , if you cant a specific username to access the uploader and when you put "1"
            a new cell appear in index.php so as tp put the username which you epecify, and they are in these lines:

            // authorization
            $user1 = "1" ; //if you want to to use it by a valid username put "1"

            // the name of the user
            $user = "test" ;

            if you did not put "1" the cell of the username login will not appeare

            so $text1
            is the input text you will input while the $user1= "1"
            so the script will match the $text1 with the $user, if they are the same will continue if not error message :
            wrong username

            $size_round
            I do not know, but you can see it here:
            $size_round = round (($size_end * 1024) ,0);
            $size1 = round(($file1_s ize / 1024),1) ;
            $size2 = round(($file2_s ize / 1024),1) ;
            $size3 = round(($file3_s ize / 1024),1) ;
            $sizeall =$size1+ $size2+ $size3;

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #21
              $ar1ar
              you can find it here

              <form method=\"POST\" action=\"$PHP_S ELF?ar1ar=up\" enctype=\"multi part/form-data\">

              And when the upload finish another page will come wih results and in the address url will look like this

              http://localhost/upload/index.php?ar1ar=up
              exactly. but it only works with register_global s on. since PHP 4, URL parameters are put into the $_GET superglobal, hence $ar1ar = $_GET["ar1ar"]; (at the very least)

              Comment

              • studsir
                New Member
                • Jun 2012
                • 22

                #22
                so only change $ar1ar
                to
                $_GET["ar1ar"]

                or
                $_GET['ar1ar']

                and what about the other variables.
                what is the final modification index.php page

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #23
                  the other variables have to be treated accordingly.

                  Comment

                  • studsir
                    New Member
                    • Jun 2012
                    • 22

                    #24
                    ok I will try.

                    Thank you very much

                    Comment

                    • studsir
                      New Member
                      • Jun 2012
                      • 22

                      #25
                      After big efforts I finally converted it without any errors. except the files are not uploaded in the Up directory

                      but the reslut page give everything is ok.

                      You can try it , here is my final index.php


                      Code:
                      <?php 
                      
                      
                      //  ************ you should change  ******************** 
                      /*  The change only between the quotations */ 
                      
                      // Name of the site 
                      $neme_sate = ""; 
                      
                      // The upload folder 
                      $Dir = "up"; 
                      
                      //the path of the upload script, and must end with "/" 
                      $ULR = "http://localhost/"; 
                      
                      //  ************ Optional  ************************ 
                      
                      // authorization 
                      $user1 = "1" ;  //if you want to to use it by a valid username put "1" 
                      
                      // the name of the user 
                      $user = "test" ; 
                      
                      //maximun file size in kb 
                      $size_end = "200"; 
                      
                      // specify the files 
                      $exten = array (".jpg",".JPG"); 
                      
                      
                      //  ***********  style modifications ****************** 
                      //page backround 
                      $body = "EDF3F3";  
                      // table color borders 
                      $color1 = "006F00";  
                      // table color head 
                      $color2 = "669999";  
                      // table background color 
                      $color3 = "E1ECEC"; 
                      // font color head 
                      $font_color1 = "E1ECEC"; 
                      // font color content 
                      $font_color2 = "000000 "; 
                      
                      
                      //***************************************************** 
                      // changing this, the uploader will not work 
                      //***************************************************** 
                      $text1 = $_POST['text1'];
                      $file1_name = $_FILES['file1_name']['name'];
                      $file2_name = $_FILES['file2_name']['name'];
                      $file3_name = $_FILES['file3_name']['name'];
                      $file1_size = $_FILES['file1_name']['size'];
                      $file2_size = $_FILES['file2_name']['size'];
                      $file3_size = $_FILES['file3_name']['size'];
                      $exten1 = strrchr($_FILES['file1_name']['name'] ,'.');
                      $exten2 = strrchr($_FILES['file2_name']['name'] ,'.');
                      $exten3 = strrchr($_FILES['file3_name']['name'] ,'.');
                      $size_round = round (($size_end * 1024) ,0);
                      $size1 = round(($file1_size / 1024),1) ;
                      $size2 = round(($file2_size / 1024),1) ;
                      $size3 = round(($file3_size / 1024),1) ;
                      $sizeall =$size1+ $size2+ $size3;
                      $fp = fopen ("count.txt", "r");
                      $bytes = 7;
                      $buffer = fread($fp, $bytes);
                      fclose ($fp);
                      $fp2 = fopen ("count.txt", "w+");
                      fwrite ($fp2, $buffer+1);
                      fclose ($fp2);
                      $Count=$buffer+1;
                      echo "<body>"; 
                      echo " 
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"  height=\"100%\">
                            <tr><td width=\"100%\" valign=\"\"> 
                            <p align=\"center\"><b> 
                            "; 
                         switch ($_GET['ar1ar'])
                              { 
                            default: 
                           echo "<html>"; 
                           echo "<title>$neme_sate</title>"; 
                      echo "<CENTER> 
                      <form method=\"POST\" action=\"$PHP_SELF?ar1ar=up\" enctype=\"multipart/form-data\">
                       <div align=\"center\"> 
                      <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\" bordercolor=\"$color1\" width=\"90%\">
                       <tr><td width=\"100%\" style=\"padding-right: 20\">
                       <p style=\"margin-top: 0; margin-bottom: 0\"><b>term of use</b></td>
                       </tr> 
                              <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                              <p align=\"center\" style=\"margin-top: 3; margin-bottom: 3\"> 
                              <font color=\"$font_color2\"> <b>The size of the image should be smaller than :  ( $size_end ) kb</b></font>
                               </td></tr> 
                               </table> 
                               <p align=\"center\" style=\"margin-top: 2; margin-bottom: 2\">&nbsp;</p> ";
                                if ($user1 == "1") 
                               { 
                               echo " 
                             <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\"  bordercolor=\"$color1\" width=\"90%\">
                             <tr> 
                              <td width=\"100%\" bgcolor=\"FEF9DA\" style=\"padding-right: 20\"> 
                              <p style=\"margin-top: 0; margin-bottom: 0\"><font color=\"$font_color2\"><b>login</b></font></td>
                             </tr> 
                              <tr><td width=\"100%\" bgcolor=\"$color3\"> 
                              <p align=\"center\" style=\"margin-top: 5; margin-bottom: 5\"> 
                                 <font color=\"$font_color2\"><b>The username :&nbsp;</b></font><input type=text name=text1 size=50>
                             </td></tr> 
                             </table> 
                                "; 
                             } 
                               echo " 
                               <p align=\"center\" style=\"margin-top: 2; margin-bottom: 2\">&nbsp;</p>
                                <table border=\"1\" cellpadding=\"\0\" cellspacing=\"0\" bordercolor=\"$color1\" width=\"90%\">
                             <tr> 
                              <td width=\"100%\" style=\"padding-right: 20\">
                               <p style=\"margin-top: 0; margin-bottom: 0\"><b>upload images</b></td>
                             </tr> 
                            <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                              <p align=\"center\" style=\"margin-top: 5; margin-bottom: 5\"> 
                               <input type=file name=file1_name size=50><br> 
                               <input type=file name=file2_name size=50><br> 
                               <input type=file name=file3_name size=50><br> 
                            </td></tr> 
                            <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> 
                              <p align=\"center\" style=\"margin-top: 3; margin-bottom: 3\"> 
                              <font color=\"000000\"><b> 
                              <button name=\"submit\" type=\"submit\">upload</button> 
                              <input type=\"reset\" value=\"reset\" name=\"B2\"> 
                              </b></font> 
                              </td></tr></table> 
                              </form> 
                                "; 
                                echo "$Count : number of visits<br>"; 
                               break; 
                              case "up": 
                              echo "<title>$neme_sate</title>"; 
                              if (($user1=="1") && ($_POST['text1'] <> "$user")) 
                              { 
                                echo  " 
                               <div align=\"center\"> 
                               <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
                                  <tr> 
                               <td width=\"100%\" bgcolor=\"$color2\" style=\"padding-right: 20\"> 
                               <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"$font_color1\"><b>error</b></font></td>
                                 </tr> 
                                <tr><td width=\"100%\" bgcolor=\"$color3\">"; 
                                echo "<font color=\"$font_color2\"><b><br>wrong username<br><br></b></font>";
                                 echo " </td></tr></table><br> "; 
                               } 
                               else{ 
                               if ($user1 == "1") 
                             { 
                              echo  " 
                           <div align=\"center\"> 
                           <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
                              <tr> 
                               <td width=\"100%\" bgcolor=\"$color2\" style=\"padding-right: 20\"> 
                               <p style=\"margin-top: 3; margin-bottom: 3\"><font color=\"$font_color1\"><b>login username</b></font></td>
                              </tr> 
                           <tr><td width=\"100%\" bgcolor=\"$color3\"> "; 
                             echo "<font color=\"$font_color2\">  welocome $text1 </font><br>"; 
                             echo " </td></tr></table><br> "; 
                             } 
                           echo  " 
                          <div align=\"center\"> 
                           <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" width=\"90%\">
                       
                              <tr> 
                               <td width=\"100%\" style=\"padding-right: 20\">
                                <p style=\"margin-top: 3; margin-bottom: 3\"><b>feild one information</b></td>
                               </tr> 
                      
                             <tr><td width=\"100%\" bgcolor=\"FEF9DA\">"; 
                      
                      
                               if ($file1_name == "") 
                                  echo "<br><font color=\"$font_color2\">you did not input any image</font><br>";
                       
                               elseif (file_exists("$Dir/$file1_name")) 
                                  echo "<br><font color=\"$font_color2\">the name of the image is already found </font><br><br>";
                       
                               elseif (!in_array( $exten1 , $exten)) 
                                  echo "<br><font color=\"$font_color2\">the file extinsion is not allowed</font><br><br>";
                       
                               elseif ($file1_size > "$size_round") 
                                  echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size1 and the maximun file size is $size_end kb</font><br><br>";
                       
                               else { 
                                  @copy($file1, "$Dir/$file1_name"); 
                                  echo"<font color=\"$font_color2\">The image is uploaded</font><br>";
                                   echo"<font color=\"$font_color2\">The size of the image :  $size1 kb  </font><br>";
                                   echo"<font color=\"$font_color2\">Image url : </font><br>"; 
                                  echo"<a target=\"_blank\" href=\"$ULR$Dir/$file1_name\">$ULR$Dir/$file1_name</a><br><br>";
                                     } 
                              echo " </td></tr></table><br> "; 
                             echo  " 
                           <div align=\"center\"> 
                           <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" id=\"AutoNumber1\"  width=\"90%\">
                       
                             <tr> 
                               <td width=\"100%\" style=\"padding-right: 20\">
                                <p style=\"margin-top: 3; margin-bottom: 3\"><b>feild two information</b></td>
                              </tr> 
                      
                             <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> "; 
                      
                               if ($file2_name == "") 
                                  echo "<font color=\"$font_color2\"><br>you did not input any image<br></font>";
                       
                               elseif (!in_array( $exten2 , $exten)) 
                                  echo "<font color=\"$font_color2\"><br>the file extinsion is not allowed<br><br></font>";
                       
                               elseif (file_exists("$Dir/$file2_name")) 
                                  echo "<font color=\"$font_color2\"><br>the name of the image is already found <br><br></font>";
                       
                               elseif ($file2_size > "$size_round") 
                                  echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size2 and the maximun file size is $size_end kb</font><br><br>";
                       
                               else { 
                                  @copy($file2, "$Dir/$file2_name"); 
                                  echo"<font color=\"$font_color2\">The image is uploaded<br></font>";
                                   echo"<font color=\"$font_color2\">The size of the image :  $size2 kb <br></font>";
                                   echo"<font color=\"$font_color2\"> Image url :</font><br>"; 
                                  echo"<a target=\"_blank\" href=\"$ULR$Dir/$file2_name\">$ULR$Dir/$file2_name</a><br><br>";
                       
                                     } 
                               echo " </td></tr></table><br> "; 
                      
                            echo  " 
                           <div align=\"center\"> 
                           <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; padding-right: 26\" bordercolor=\"$color1\" id=\"AutoNumber1\"  width=\"90%\">
                       
                             <tr> 
                               <td width=\"100%\" style=\"padding-right: 20\">
                                <p style=\"margin-top: 3; margin-bottom: 3\"><b>feild three information</b></td>
                              </tr> 
                      
                             <tr><td width=\"100%\" bgcolor=\"FEF9DA\"> "; 
                      
                               if ($file3_name == "") 
                                  echo "<font color=\"$font_color2\"><br>you did not input any image<br></font>";
                                elseif (!in_array( $exten3 , $exten)) 
                                  echo "<font color=\"$font_color2\"><br>the file extinsion is not allowed<br><br></font>";
                                elseif (file_exists("$Dir/$file3_name")) 
                                  echo "<font color=\"$font_color2\"><br>the name of the image is already found <br><br></font>";
                               elseif ($file3_size > "$size_round") 
                                  echo "<br><font color=\"$font_color2\">The size of the image is more than allowed<br>The size of the image is  $size3 and the maximun file size is $size_end kb</font><br><br>";
                                 else { 
                                  @copy($file3, "$Dir/$file3_name"); 
                                  echo"<font color=\"$font_color2\"> The image is uploaded <br></font>";
                                   echo"<font color=\"$font_color2\">The size of the image : $size3 kb <br></font>";
                                   echo"<font color=\"$font_color2\"> Image url :</font><br>"; 
                                  echo"<a target=\"_blank\" href=\"$ULR$Dir/$file3_name\">$ULR$Dir/$file3_name</a><br><br>";
                                     }echo " </td></tr></table><br> ";} 
                                     
                                 echo"<a target=\"_self\" href=\"$PHP_SELF\">home page</a><br><br>"; 
                                echo "$Count : Number of visits<br>"; 
                                break;} 
                               echo " 
                               </td></tr> 
                                      </table> 
                      ";?>

                      Comment

                      • studsir
                        New Member
                        • Jun 2012
                        • 22

                        #26
                        by the way,
                        if the same name file in the up directory , the script will give me error that :

                        the name of the image is already found

                        which means that the variables are right, but when I delete the file and tryagain, the script gives that the image is uploaded, but there is no image file in the up directory

                        Comment

                        • Dormilich
                          Recognized Expert Expert
                          • Aug 2008
                          • 8694

                          #27
                          this comes from using the @ operator. otherwise copy() would certainly have complained.

                          Comment

                          • studsir
                            New Member
                            • Jun 2012
                            • 22

                            #28
                            I omitted it

                            and the same no errors and the image file did not uploaded to the directory

                            Comment

                            • Dormilich
                              Recognized Expert Expert
                              • Aug 2008
                              • 8694

                              #29
                              tbh, I see nothing where you save the uploaded files. you only have a call to copy() with an invalid argument (or did you define $file1 anywhere?).

                              Comment

                              • studsir
                                New Member
                                • Jun 2012
                                • 22

                                #30
                                I changed the $file1
                                to
                                Sfile1_name

                                and omitted the @

                                and the php error log gives that

                                copy(book.jpg): failed to open stream: No such file or directory in C:\apache2triad \htdocs\upload\ index1.php


                                book.jpg is the image name


                                yes the script cannot save the uploaded files

                                Comment

                                Working...