Image url retrieval php script needed !

Discussion in 'PHP' started by vishnubabuinc, Aug 18, 2011.

  1. #1
    Image upload Html form:

    <html>
    <body>
    
    <form action="uplo.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    
    
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    </body>
    </html>
    HTML:
    Image upload code:


    <?php
    if ((($_FILES["file"]["type"] == "image/bmp")|| ($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpg"))&& ($_FILES["file"]["size"] < 20000))
    {
    if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "
    ";
    }
    else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "
    ";
    echo "Type: " . $_FILES["file"]["type"] . "
    ";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
    ";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
    ";
    
    if (file_exists("c:/e/" . $_FILES["file"]["name"]))
    {
    echo $_FILES["file"]["name"] . " already exists. ";
    }
    else
    {
    move_uploaded_file($_FILES["file"]["tmp_…
    "c:/e/" . $_FILES["file"]["name"]);
    echo "Stored in: " . "c:/e/" . $_FILES["file"]["name"];
    }
    }
    }
    else
    {
    echo "Invalid file";
    }
    ?>
    PHP:
    Now i need a script which would retrieve the "Uploaded" image link from IMAGESHACK.US

    trying a wordpress plugin using this..

    can someone help me out !
    thanks.
     
    vishnubabuinc, Aug 18, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    An input with type="file" allows your user to choose a file to upload to your server. Since the file is already on your server, there's no need to "retrieve" it. This method won't allow your user to point to an image hosted on Image Shack and allow you to download it to your site (which would be illegal if your user doesn't own the image).
     
    Rukbat, Aug 22, 2011 IP