I am looking for a code(php or javascript) that can enable me to upload files to my site eg images and when i vist my site at that particular posted page i should see the image not a link but the thumb nail like what happens with gmail or face book. when I upload a file(text) i should see a link that can allow me either to view the file or download the file.

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000000000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {


    if (file_exists("images/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
        $image= time()."-". $_FILES["file"]["name"];
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "images/". $image);

      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>
<html>
<body>
<form action = "imgupload.php" enctype="multipart/form-data" method = "post">
<label> Your Image:</label>
<input type = "file" name = "file" /><br /><br />

<input type = "submit" name = "submit" value = "submit" /><br /><br />
</form>

thanks for replying, I will try it and will come back to you if any need arises.

There are hundreds of tutorials on the net on how to do this, perosnally i would rather use a tutorial than ask for the code, when you work through the tutorial you will know how and why it works, this helps you to modify it and to further develop it and solve any issues that may arise. Even though Daniel was nice enough to post some code for you, i would still recommend you find some tutorials and use those to develop exactly what you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.