Location: PHPKode > scripts > Mod's Image Uploader > mods-image-uploader/uploadp.php
<?
@include ('config.php');
$keywords = mysql_escape_string($_POST['keywords']);
/////////////////////////////////////////////////////////////////////
$ran1 = rand(10000,100000);
$ran2 = time();
$file_ext = substr($_FILES["file"]["name"], strripos($_FILES["file"]["name"], '.'));
/////////////////////////////////////////////////////////
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png"))
&& (($file_ext = "jpg")
|| ($file_ext = "gif")
|| ($file_ext = "png")
|| ($file_ext = "jpeg"))
&& ($_FILES["file"]["size"] < 1048576))
  {

if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_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 />";

    if (file_exists("upload/" . $_FILES["file"]["tmp_name"]))
      {
      echo $_FILES["file"]["tmp_name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $ran1 . $ran2 .  $_FILES["file"]["name"]);
      echo "Direct Link: " . "<a href='$address" . "upload/" .  $ran1 . $ran2 .  $_FILES["file"]["name"] . "'>Here</a>";
$linky = "$address" . "upload/" .  $ran1 . $ran2 .  $_FILES['file']['name'];
$ip = $_SERVER['REMOTE_ADDR']; 
$con = mysql_connect($host,$user,$pass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($db, $con);
$query = sprintf("INSERT INTO images (link,ip,keywords) VALUES ('$linky','$ip','$keywords')") ;
$result = mysql_query($query);
mysql_close($con);
      }
    }
  }
else
{
echo "<center>File does not meet criteria for uploading.</center>";
}
?>

<html>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<center>
<font size="1">Copyright © 2008 MOD_CHAMPION & New Earth Programming Team</font>
</center>
</html>
Return current item: Mod's Image Uploader