درخواست اسکریپت آپلود عکس

با سلام
ذوستان عزیز یه اسکریپت آپلود عکس شبیه این میخوام
http://img.majidonline.com/index.php
اگه کسی سراغ داره پیشاپیش نوکرشیم
من هر چی سرچ کردم یه چیز توپ پیدا نکردم
اگه هم همین نسخه پولی هست یا کسی مستونه برام بنویسه
خبرم کنید
خیلی واجبه
پیشاپیش قربون مرامتون
 

parsmizban

Member
سلام

index.htm
PHP:
<html>

<head>
<title>Image Upload With Preview</title>

<style type="text/css">
.imagePreview {background-color:#99cccc;width:60px;height:45px;text-align:center;vertical-align:middle;border:1px black solid}
</style>

<script type="text/javascript">
function imgUpload(msgZoneId) {
	// Display Loading... message and upload image 
	msgZone = document.getElementById("imgZone" + msgZoneId)
	msgZone.innerHTML = "<span style=\"font-size:8px\">Loading...</span>"
	document.getElementById("uploadForm").submit()
}

function imgRollBack(msgZoneId) {
	// Display ? in the image box if upload fails
	msgZone = document.getElementById("imgZone" + msgZoneId)
	msgZone.innerHTML = "?"
}

function imgPreview(zoneId,imgPath) {
	// Display uploaded image
	msgZone = document.getElementById("imgZone" + zoneId)
	msgZone.innerHTML = "<img src=\"" + imgPath + "\" width=\"60\" height=\"45\"/>"
	imgStorePath(zoneId,imgPath)
}

function imgStorePath(zoneId,imgPath) {
	// Store image path
	document.getElementById("imgPath" + zoneId).value = imgPath
}
</script>

</head>

<body>
<div class="imagePreview"><table border="0" cellpadding="0" cellspacing="0" width="60"><tr><td height="45" align="center" valign="middle" style="color:#408080;font-family:Arial;font-size:14px;font-weight:bold;" id="imgZone1">?</td></tr></table></div>
<iframe name="uploadFrame" width="60" height="50" scrolling="no" style="display:none;"></iframe>
<form name="uploadForm" action="preview.php" method="post" enctype="multipart/form-data" target="uploadFrame">
	Local File Path : <input type="file" size="60" name="myFile"/>
	<input type="hidden" name="max_file_size" value="20000"/>
	<input type="button" value="Upload" onclick="imgUpload(1)"/>
	<input type="hidden" value="1" name="zoneId"/>
	<input type="text" value="" name="imgPath1"/>
</form>
</body>
</html>

preview.php
PHP:
<?
function getPath() {
	global $SCRIPT_FILENAME;
	$tmp = split("[/]",$SCRIPT_FILENAME);
	$tmp = $tmp[count($tmp)-1];
	$tmp = str_replace($tmp,"",$SCRIPT_FILENAME);
	return $tmp;
}

function isImage($imageFile) {
	// Allow GIF/JPG/PNG files
	$isImage = $imageFile[2]<4;
	return $isImage;
}

function checkImageSize($imageFile,$imageWidth,$imageHeight) {

	if ($imageFile[0]==$imageWidth && $imageFile[1]==$imageHeight) {
		return true;
	} else {
		return false;
	}
}

// Allow only image file
if (!$imageFile = @getImageSize($HTTP_POST_FILES["myFile"]["tmp_name"])) {
	$errorMessage = "Please upload a valid file";
	exit("<html><head><title>An error occured during upload process</title></head><body><script language=\"JavaScript\" type=\"text/javascript\">alert(\"$errorMessage\");parent.imgRollBack(\"$zoneId\")</script></body></html>");
}

// Allow only GIF/JPEG/PNG formats
if (!isImage($imageFile)) {
	$errorMessage = "Only GIF, JPEG or PNG files may be uploaded";
	exit("<html><head><title>An error occured during upload process</title></head><body><script language=\"JavaScript\" type=\"text/javascript\">alert(\"$errorMessage\");parent.imgRollBack(\"$zoneId\")</script></body></html>");
}

// Check image size
$imageWidth=60; // All images should have a width of 60 pixels
$imageHeight=45; // All images should have an height of 45 pixels

if (!checkImageSize($imageFile,$imageWidth,$imageHeight)) {
	$errorMessage = "Only image with a width of 60 pixels and an height of 45 pixels may be uploaded";
	exit("<html><head><title>An error occured during upload process</title></head><body><script language=\"JavaScript\" type=\"text/javascript\">alert(\"$errorMessage\");parent.imgRollBack(\"$zoneId\")</script></body></html>");
}

// Check image weight
$imageWeight=5000; // Images should be less than 5k

if ($HTTP_POST_FILES["myFile"]["size"]>=$imageWeight) {
	$errorMessage = "Only image with a weight under 5k may be uploaded";
	exit("<html><head><title>An error occured during upload process</title></head><body><script language=\"JavaScript\" type=\"text/javascript\">alert(\"$errorMessage\");parent.imgRollBack(\"$zoneId\")</script></body></html>");
}

// Save uploaded image
$savePath = getPath() . "tmp/" . $HTTP_POST_FILES["myFile"]["name"];
$isValidUpload = move_uploaded_file ($HTTP_POST_FILES["myFile"]["tmp_name"], $savePath);

if ($isValidUpload) {
	// Valid upload, display preview
	print "
	<html>
	<head><title>Valid upload, display preview</title></head>
	<body>
	<script language=\"JavaScript\" type=\"text/javascript\">
	parent.imgPreview(\"$zoneId\",\"tmp/".$HTTP_POST_FILES["myFile"]["name"]."\")
    </script>
	</body>
	</html>";
} else {
	// Invalid upload
	$errorMessage = "Invalid upload";
	exit("<html><head><title>An error occured during upload process</title></head><body><script language=\"JavaScript\" type=\"text/javascript\">alert(\"$errorMessage\");parent.imgRollBack(\"$zoneId\")</script></body></html>");
}
?>
موفق باشید
 

miladmovie

Active Member
لطفا ! خواهش می کنم تاپیکت رو در جای مناسب باز کنید


منتقل شد به بخش اسکریپت آماده
 

جدیدترین ارسال ها

بالا