PHP|img in "Browse" button & "text box"

Discussion in 'PHP' started by Tal_el, Nov 11, 2007.

  1. #1
    how can i put image in the "Browse" button on system "UploadImage"
    example:
    [​IMG]
    and how i cant put image for the "text box" on the "UploadImage" system
    example:
    [​IMG]

    the code:
    <?php
    
    define("MAX_FILE_SIZE", 100);
    define("UPLOAD_DIR", "**censored **\**censored **\**censored *\*censored **\img");
    $FileTypes = array("image/pjpeg",
              "image/gif",
              "image/jpg",
              "image/png");
    
    ?>
    
    
    <html>
    <center>
    <head>
     <title></title>
    </head>
    
    <body>
    <img src="images/logo.gif">
    <BODY background="images\main-bg.gif">
    </BODY>
    <br><br>
    
    <?php
    
    if(!@$_POST['image'])
    {
        ?>
        <form enctype="multipart/form-data" action=<?php echo '"'.$_SERVER['PHP_SELF'].'"'; ?> method="POST">
    
                        <input type="file" name="file" size=img="images\bro.gif">
    <br><br>
     
          
     
    
        <input type="image" name="image" src="***\***\***\***\images\up.gif" >
    
    
        </form>
        <?php
    echo date("j/n/Y H:i" , time() );
    }
    else
    {
        //echo $_FILES['file']['type'].'<BR>';
    
        $is_ValidType = false;
    
        foreach($FileTypes as $Type)
        {
            if($_FILES['file']['type'] == $Type)
            {
                $is_ValidType = true;
                break;
            }
        }
    
        if($is_ValidType)
            if(($_FILES['file']['size']/1024) > MAX_FILE_SIZE)
                echo "File is too big. Maximum size allowed is ".MAX_FILE_SIZE." kb.";
            else
                if(move_uploaded_file($_FILES['file']['tmp_name'], UPLOAD_DIR."\\".$_FILES['file']['name']))
                    echo "File was succefully uploaded!";
                else
                    echo "Uploading failed. Please try again.";
        else
            echo "Wrong file type.";
    
    
    
    }
    
    
    ?>
    
    </body>
    </center>
    </html>
    
    
    
    PHP:

     
    Tal_el, Nov 11, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Not with PHP. Actually I'm not even sure if this is possible without Flash or javascript.


    Oh yeah, and your script is pretty insecure. Don't rely on the type value in the $_FILES array since it comes from the client and can not be trusted.
     
    nico_swd, Nov 11, 2007 IP
  3. Tal_el

    Tal_el Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i think this is with css so i send this Thread in css forum
     
    Tal_el, Nov 11, 2007 IP
  4. jonimontana

    jonimontana Well-Known Member

    Messages:
    262
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Easy...

    for better info , goto Css forum.
     
    jonimontana, Nov 11, 2007 IP