Location: PHPKode > projects > Free Blog Creator > freeblog/up.php
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upload</title>
<style type="text/css">
<!--
form{display:inline}
-->
</style>
<script type="text/javascript">
<!--
function chooseImage(id) {
window.opener.focus();
window.opener.includeImage(
id
);
window.close();
}
//-->
</script>
</head>
<body>

<form action="" method="POST" enctype="multipart/form-data">
<input type=file name=file size=30><br>
<input type=submit name="up" value=Upload></form>

<?php
if($_POST["up"]){

if($_FILES['file']['name'] != ""){
$File=$_FILES['file']['name'];
$fp = fopen($_FILES['file']['tmp_name'], "rb");
$imgs = '';
while (!feof($fp)) {
$imgs .= fread($fp, $_FILES['file']['size']);
}
fclose($fp);

$fp=fopen("./log/images/$File","w");
fputs($fp,$imgs);	
fclose($fp);
chmod("./log/images/$File",0666);

}
}
?>

<?php
if($_GET['del']){ 
$id=$_GET['del'];
unlink("./log/images/$id");
}
?>


<?php
$updir = "./log/images/";
$dir_file = opendir( $updir );
while (false !== ($file_name = readdir($dir_file))) {
if(is_file("$updir/$file_name") && $file_name != "." && $file_name != ".."){

$dirlist[]=$file_name;

}        
}
closedir( $dir_file );
?>
<?php
if(sizeof($dirlist)) {

$Rows=10;

if(!$_GET['p']) {
$p=1;
}
$L=$p-1;
$Top=$L * $Rows+1;
$Size=sizeof($dirlist);
$Last=$p * $Rows;
if($Last>$Size){
$Last=$Size;
}
?>
<br />Files <?=$Top?> - <?=$Last?> of <?=$Size?><br />
<table width='400'>
<?php
$p=$p-1;
$start = $p * $Rows;
$end   = $start + $Rows;

for($i = 0; $i < count($dirlist); $i++){

if($i < $start) continue;
if($i >= $end)  break;

$filename = $dirlist[$i];
$dump = strlen($filename);
if( $dump > 12 ){
$filename = substr($filename, 0, 12);
$filename = substr($filename , 0, strrpos($filename , " "));
$filename .="...";
}
?>
<tr><td width='50%'><a href="" onclick="chooseImage('<?=$dirlist[$i]?>')" title="<?=$dirlist[$i]?>"><?=$filename?></a></td><td width='5%'><a href="./log/images/<?=$dirlist[$i]?>" title="Preview" onclick="window.open(this.href); return false;">Preview</a></td><td width='5%'><a href="?del=<?=$dirlist[$i]?>">Del</a></td></tr>
<?php
}
?>
</table>
<?php
$Interval = 6;
$Total = $Size/$Rows;                
$Link = "up.php?p=";
$P = ($_GET[p]) ? $_GET[p] : 1;

if ($P > 1) {
  $Page .= "<a href=".$Link.($P - 1).">Previous</a> ";
}
for ($i = $P - $Interval; ($i <= $P + $Interval) && ($i <= $Total); $i++) {
  if ($i < 1) continue;
  if ($i == $P) {
    $Prev = "<strong>";
    $Next = "</strong> ";
  } else {
    $Prev = "<a href='".$Link.$i."'>";
    $Next = "</a> ";
  }
  $Page .= $Prev.$i.$Next;
}
if ($P < $Total) {
  $Page .= "<a href=".$Link.($P + 1).">Next</a> ";
}
echo $Page;
}
?>
</body>
</html>
Return current item: Free Blog Creator