[wanted] Image.......

Discussion in 'PHP' started by Copper Python, Nov 7, 2007.

  1. #1
    Im wanting an Image Up-Loader Script kind of like :www.tinypic.com or photobucket

    Can anyone give me a script or a link to a script?
     
    Copper Python, Nov 7, 2007 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    heres a simple image uploader or file uploader



    
    //file format, type and size
    if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Error: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Stored in: " . $_FILES["file"]["tmp_name"];
        }
      }
    else
      {
      echo "Invalid file";
      }
    
    PHP:
    html code

    
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" /> 
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    HTML:
    hope this help
     
    bartolay13, Nov 7, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    The above code would not work. And if it did, it would not be secure. Never rely on the type value provided by the $_FILES array, as it comes directly from the browser. And therefore it can't be trusted.
     
    nico_swd, Nov 7, 2007 IP
  4. linkstraffic

    linkstraffic Well-Known Member

    Messages:
    388
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    133
    #4
    And what do you suggest nico_swd?
    Ftp, applet

    May be a combination of the last script and ajax would be a good alternative.
     
    linkstraffic, Nov 7, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    nico_swd, Nov 7, 2007 IP
  6. redlorry919

    redlorry919 Peon

    Messages:
    384
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    redlorry919, Nov 7, 2007 IP
  7. mystery

    mystery Banned

    Messages:
    744
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Check out my sig, for the hands down BEST image script there is.... Drop me a PM ;)
     
    mystery, Nov 11, 2007 IP