Simple Image Upload [PHP]

ak007

Member
Messages
216
Reaction score
0
Points
16
Ive Made This Simple Image Upload Script For Use In Uploading Images Like Screenshots Sigs or Avatars Currently in Beta (Made In 10 min ;) )

Some Features :
Easy To Setup
Filesize Limit
Format Limit (Only Images)
Random File Name Genration According To User Input And Type
Eaisly Integrate With Your Site
Hope You Enjoy It Comments Are Welcomed :)

PHP:
<?php
if(!empty($_POST)){
########   Basic Settings	########
// Your Root Directory 
$base = "/home/username/public_html/";
//The Directory Where Files Will Be Uploaded
$dir = "/uploads/";
// Your Site URL
$url = "http://****x10hosting.com";
####################################
$allowded = array("image/bmp","image/pjpeg" , "image/jpeg" , "image/gif" , "image/png" , "image/jpg");
$name = $_POST[name];
$type = $_POST[type];
$rand = rand( 100 , 20000);
//echo $_FILES[file][type];
//echo $_FILES[file][tmp_name];
		if(empty($_POST[name]) || empty($_POST[type])){
		echo "You Forgot To Fill the required Feild Please Fix The Error";
		 		 		 		 	}
		elseif(!in_array($_FILES[file][type] , $allowded)){
		echo "Un Expected File Format Only Images Supported";
		 		 		 		 		}
		 		elseif($_FILES[file][size] >= 500000){
		 		echo "Too Large File!!! Maximum File Size Allowded IS 500 kb!!";
					}
		 		 		 		 		
				else{
		 	$filename = $name."_"."$type"."_".$rand."_".$_FILES[file][name];
				$file = $base.$dir.$filename;
				//echo $file;
		 	$upload = move_uploaded_file($_FILES[file][tmp_name] , $file);
				chmod($file , 0755);
				//echo $_FILES[file][size];
				if($upload){
		 	echo "File Uploaded Sucessfully !!! <br><a href=\"".$url.$dir.$filename. "\">Click Here To view your File</a> &nbsp; <br>";
		 	echo "Your Code To Post That Image In Forum Is <b> : [IMG]".$url.$dir.$filename."[/IMG]</b><br>";
		 	echo "Just Copy the Above Code And paste It Where You Wana See this Image In the forum";
				exit;
				
				
						}
				}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #00FF33;
}
body {
	background-color: #000000;
}
.style1 {
	font-size: 18px;
	font-weight: bold;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFFFFF;
}
a:hover {
	text-decoration: underline;
	color: #FFFFFF;
}
a:active {
	text-decoration: none;
	color: #FFFFFF;
}
-->
</style></head>

<body>
<div align="center">
  <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
	<table width="431" border="0" align="center">
	  <tr>
		<td colspan="2"><div align="center"><span class="style1">~~~Upload~~~</span></div></td>
	  </tr>
	  <tr>
		<td width="131">Your Name </td>
		<td width="290"><input name="name" type="text" id="name" /></td>
	  </tr>
	  <tr>
		<td><div align="left">Picture Type <br />
		</div></td>
		<td><select name="type" id="type">
		  <option>Sig</option>
		  <option>Wallpaper</option>
		  <option>Screenshot</option>
		</select>
		</td>
	  </tr>

	  <tr>
		<td><label>Select Your File : </label></td>
		<td><input type="file" name="file" /></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
		<td><input type="submit" name="Submit" value="Submit" /></td>
	  </tr>
	</table>
  </form>
</div>
</body>
</html>

Upcoming Features:
User Management
Full Installation Setup
Anti-Spam System
Upload Limit Per User
Ip Banning
And More......
 
Last edited:
Top