Results 1 to 2 of 2

Thread: Script For Uploading Text and Pictures

  1. #1
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Script For Uploading Text and Pictures

    I have recently made a Motor Car website http://www.luckymotors.org
    I wish to incorporate a Script for the advertisors on my site.
    First they have to register with their name and Email address.
    Then they can upload the details of their car they want to sell.
    They should also be able to upload a few pictures of the car they want to sell.
    Can any one help?
    Thanks.

    Maria

  2. #2
    Join Date
    Apr 2009
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile

    hmmmm... I have a simple uploader-script that works fine. But I don't know how to make a varification-by-mail on it...
    But I once changed it to, at least, having a password-protection.

    Make an index.php - this one includes the password-protection:
    Code:
    <?php
    
    $password = "YOU_CUSTOM_PASSWORD";  
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><head><title>upload</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    P { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
    TD { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
    -->
    </style>
    </head>
    <body>
    <?php 
    // If password is valid let the user get access
    if (isset($_POST["password"]) && ($_POST["password"]=="$password")) {
    ?>
    
    <form enctype="multipart/form-data" action="upload.php" method="POST">
      <p align="center"><font size="3" face="Arial, Helvetica, sans-serif"><strong>CHOOSE FILE TO UPLOAD:</strong></font></p>
      <p align="center"><br>
        <input name="uploaded" type="file" />
      </p>
      <p align="center"><br />
        <input type="submit" value="Upload" />
      </p>
    </form>
    <?php 
    }
    else
    {
    // Wrong password or no password entered display this message
    if (isset($_POST['password']) || $password == "") {
      print "<p align=\"center\"><font color=\"red\"><b>WRONG PASSWORD</b><br>TYPE CORRECT PASSWORD</font></p>";}
      print "<form method=\"post\"><p align=\"center\">PLEASE TYPE IN PASSWORD<br>";
      print "<input name=\"password\" type=\"password\" size=\"10\" maxlength=\"10\"><input value=\"Login\" type=\"submit\"></p></form>";
    }
    
    ?>
    </body></html>
    The, if correct password has been entered, it call's the site with the uploader:

    Make a upload.php:
    Code:
    <?php 
    $target = "upload/"; 
    $target = $target . basename( $_FILES['uploaded']['name']) ; 
    $ok=1; 
    
    if ($uploaded_size > 350000) 
    { 
    echo "THE FILE IS TO BIG.<br>"; 
    $ok=0; 
    } 
    
    if ($uploaded_type =="text/php") 
    { 
    echo "YOU CAN NOT UPLOADE PHP FILES<br>"; 
    $ok=0; 
    } 
    
    if ($ok==0) 
    { 
    Echo "SOMETHING WENT WRONG"; 
    } 
    
    else 
    { 
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
    { 
    echo "THE FILE ". basename( $_FILES['uploadedfile']['name']). " HAS BEEN UPLOADET"; 
    } 
    else 
    { 
    echo "SOMETHING ****ED UP :o("; 
    } 
    } 
    ?>
    You might have spotted some great features:
    You can set a max sixe to files, and even exclude some extensions (In this case, the uploader won't accept PHP-files).

    Hope this was useful

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
  •