- Joined
- Nov 10, 2008
- Messages
- 46
- Reaction score
- 45
скрипта е писан от мен преди много време и е съвсем елементарен за целта създавате една папка images която оставяте празна и пишете този код
после save и сте готови
П.С. по дефолт след като качите някоя картинка линка се рефрешва автоматично на gallery.php за целта , намерете реда echo
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
и
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
}
else
{
echo "Картинката не беше качена.";
и го заменяте с imenafailavi.php . надявам се да ви хареса успех
П.С.2 за въпроси и възникнали грешки драснете някой ред в темата
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>galleria</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">
<title>Галерия</title>
<style type="text/css">
body
{
background: #CC0000;
}
#konteiner
{
width: 820px;
background: #FFF8F0;
}
.div{
width:200px;
height:200px;
float:left;
border:2px solid #CC0000;
margin:2px;
}
.imginfo
{
color: #00008B;
text-decoration: none;
font-size: 10;
font-family: Arial, Helvetica, sans-serif;
}
A:LINK
{
color: #00008B;
text-decoration: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
}
A:Visited
{color: #00008B;
text-decoration: none;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
}
A:Hover
{color: #00008B;
text-decoration: underline;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<script type="text/javascript">
PositionX = 100;
PositionY = 100;
defaultWidth = 200;
defaultHeight = 200;
var AutoClose = true;
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="'+imageTitle+'" src='+imageURL+' style="display:block"></body></html>');
close();
}}
</script>
</head>
<body>
<center><a href="?act=up">add file</a></center><br/>
<center>
<div id="konteiner">
<?php
//config file
$img_folder = "./images";
$maxw="190";
$maxh="170";
//config file
//function size img
function razmer_kartinka($img,$maxw,$maxh)
{
list($width,$height) = @getimagesize($img);
if($width>$maxw)
{
$neww=$maxw;
$newh=$height/($width/$maxw);
}
elseif($height>$maxh)
{
$newh=$maxh;
$neww=$width/($height/$maxh);
}
elseif(($width<=$maxw) AND ($height<=$maxh))
{
$newh=$height;
$neww=$width;
}
return "<a href=\"javascript:popImage('".$img."','".$img."')\"><img src='".$img."' width='".$neww."' height='".$newh."' alt='".$img."' border='0'></a>";
}
//function size img
//function extension
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
//function extension
//function extension
function imagesize($str) {
$size = filesize($str);
$i=0;
$iec = array("K", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
while (($size/1024)>1) {
$size=$size/1024;
$i++;
}
list($width,$height) = @getimagesize($str);
return "Width: ".$width."px Height: ".$height."px<br>Размер: ".substr($size,0,strpos($size,'.')+3)." ".$iec[$i];
}
//function extension
$act=$_GET['act'];
if($act=="up")
{
echo "<form action='' method='post' name='form' enctype=\"multipart/form-data\">
<input name='ufile' type=\"file\" id='ufile' size=\"50\" /><br/>
<input type='submit' name='Submit' value='Качване'>
</form>";
if($_POST['Submit'])
{
if($_FILES['ufile']['name'] !="")
{
$ext=getExtension($_FILES['ufile']['name']);
if(($ext=='jpg') OR ($ext=='jpeg') OR ($ext=='gif') OR ($ext=='png') OR ($ext=='JPG') OR ($ext=='JPEG') OR ($ext=='GIF') OR ($ext=='PNG'))
{
$im_name=time().".".$ext;
$ok=copy($_FILES['ufile']['tmp_name'],$img_folder."/".$im_name) or die('error 1');
}
}
if($ok)
{
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
}
else
{
echo "Картинката не беше качена.";
}
}
}
elseif($act=="del")
{
$file=$_GET['file'];
$ok=@unlink($img_folder."/".$file);
if($ok)
{
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
}
}
else
{
$dh = opendir($img_folder);
while($item = readdir($dh))
{
if($item != "." and $item != "..")
{
if(is_dir($dir.$item))
{
}
else
{
print "<div class='div'><table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\" align=\"center\">".razmer_kartinka($img_folder."/".$item,$maxw,$maxh)."</td></tr><tr><td height=\"25\" valign=\"top\" align=\"center\" class=\"imginfo\">".imagesize($img_folder."/".$item)."</td></tr><tr><td height=\"22\" align=\"center\"><a href='?act=del&file=".$item."'>[Изтрии]</a></td></tr></table></div>";
}
}
}
}
?>
</div>
</center>
</body>
</html>
после save и сте готови
П.С. по дефолт след като качите някоя картинка линка се рефрешва автоматично на gallery.php за целта , намерете реда echo
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
и
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=gallery.php\">";
}
else
{
echo "Картинката не беше качена.";
и го заменяте с imenafailavi.php . надявам се да ви хареса успех
П.С.2 за въпроси и възникнали грешки драснете някой ред в темата