/*program named
as
uploadfile.php*
/
<?php
$path="up
loaded
files/";/
/path where the
uploaded images
have to be
saved
$today =
date('dmYhms'
);
$name=$_FILES[
'upload']['na
me'];
$fullpath=$path
.$name;
$type=$_FILES[
'upload']['ty
pe'];
if
($_FILES['uplo
adfile']['err
or'] > 0)
{
echo
"Error:
" .
$_FILES['uploa
dfile']['erro
r'] .
"<br
/>";
}
else
{
if(($type!=&
quot;image/jpeg
"

&& ($ty
pe!="imag
e/gif"

&& ($ty
pe!="imag
e/png"

||
(($_FILES['upl
oad']['size'
]>1024)))
{
echo
"Either
your file
exceeds the
limit or an
invalid
file";
}
else
{
echo
"Upload:
"
.$_FILES['uplo
ad']['name']
. "<br
/>";
echo
"Type:
" .
$_FILES['uploa
d']['type']
. "<br
/>";
echo
"Size:
" .
($_FILES['uplo
ad']['size']
) . "
Bytes<br
/>";
echo
"Stored
as: " .
$_FILES['uploa
d']['name'];
move_uploaded_f
ile($_FILES['u
pload']['tmp_
name'],$fullpa
th);
}
}
?>
<!DOCTYPE
html PUBLIC
"-//W3C//
DTD XHTML 1.0
Transitional//E
N"
"http://w
ww.w3.org/TR/xh
tml1/DTD/xhtml1
-transitional.d
td">
<html
xmlns="ht
tp://www.w3.org
/1999/xhtml&qu
ot;>
<head>
<meta
http-equiv=&qu
ot;Content-Type
"
content="
text/html;
charset=iso-885
9-1"
/>
<title>Up
loading a
file</title&
gt;
</head>
<body>
<form
method="p
ost"
action="u
ploadfile.php&
quot;
enctype="
multipart/form-
data">
<input
type="fil
e"
name="upl
oad"
/>
<input
type="sub
mit"
value="Up
load"
name="upl
oad"
/>
</form>
<?php
if(is_dir($path
))
{
if($open=opend
ir($path))
{
while(($file
[]=readdir($ope
n))!==false)
{} ?>
<table
width="10
0%"
border="0
">
<tr>
<td>File
Name</td>
<td>Type&
lt;/td>
<td>Size&
lt;/td>
<td>Thum
b
Nail</td>
<td>Dimen
sion</td>
<td>Downl
oad</td>
<td>Delet
e</td>
</tr>
<?php
foreach($file
as $val)
{
if(($val!=&quo
t;."

&&
($val!=".
."

&&
($val!="T
humbs.db"<
img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>&&
amp;($val!=&qu
ot;"

)
{
?>
<tr>
<td><?
php echo $val;
?></td>
;
<td><?
php
$ext=pathinfo($
val); echo
$ext['extensio
n'];
?></td>
;
<td><?
php $size=
round(filesize(
$path.$val)/102
4); echo
$size."KB
";
?></td>
;
<td><
img
src="<
?php echo
$path.$val;
?>"
style="wi
dth:30px;height
:30px;"
/></td>
;
<td><?
php $dim =
getimagesize($p
ath.$val); echo
$dim[0]."
x
".$dim[1]
;
?></td>
;
<td><a
href="dow
nload.php?file=
<?php echo
$val;
?>">
;Download</a
></td>
<td><a
href="del
ete.php?file=&l
t;?php echo
$val;
?>">
;Delete</a&g
t;</td>
</tr>
<?php
}
}
}
closedir($open
);
} ?>
</table>
</body>
</html>
/*program
delete.php*/
<?php
$file =
$_GET['file']
;
global
$uploaddir;
$uploaddir=&q
uot;uploaded
files/";
$path =
$uploaddir;
deleteFile($pa
th,$file);
function
deleteFile($pat
h,$file)
{
if(file_exist
s($path.$file))
{unlink($path
.$file);}
header("
;Location:uploa
dfile.php"

;
}
?>