PHP album feature implementation (including PHP image upload, background management, browse and delete) Tutorial examples,
Album feature implementation (including PHP image upload, background management, browse and delete) Tutorial examples include five sections:
First, album Home
<title>Album Home</title> The simple photo album.
Php
error_reporting(0
);
if(!
$_get["Page"
]){
$page= 1
; }
Else
$page=
$_get["Page"
];
$filename= "Data.dat"
;
$myfile=
file(
$filename
);
$z=
$myfile[0
];
if(
$z==
NULL
){
Echo"Current number of records: 0"
; }
Else
{
$temp=
Explode("||",
$myfile[0
]);
Echo"Shared".
$temp[0]. " Article content "
;
Echo" "
;
$p _count=
Ceil(
$temp[0]/8
);
Echo"Points".
$_count." Page displays the
;
Echo" "
;
Echo"Show now."
$page." Page
;
Echo" "
;
Echo"
"
;
if(
$page!=
Ceil(
$temp[0]/8
)){
$current _size= 8
; }
Else
{
$current _size=
$temp[0]%8
; }
if(
$current _size= = 0
){
$current _size= 8
; }
for(
$i= 0;
$i<
Ceil(
$current _size/4);
$i++
){
for(
$j= 0;
$j<4;
$j++
){
$temp=
Explode("||",
$myfile[
$i*4+
$j+(
$page-1) *8
]);
if((
$i*4+
$j+(
$page-1) *8) <
$z
){
$imgfile= "./images/".
$temp[1
];
$flag=
getimagesize(
$imgfile
);
Echo"$temp[0]. " > $temp[1
];
if(
$flag[0]>180| |
$flag[1]>100
){
Echo"Width=180 height=".
Ceil(
$flag[1]*180/
$flag[0
]); }
Echo"Border=\" 0\ ">"
; }
Else
{
Echo""
; } } }
Echo""
; }
Echo"
"; $prev _page=$page-1; $next _page=$page+ 1; if($page<= 1){ Echo"First Page |"; }Else{ Echo"$PATH _info? page=1 ' > First page | "; } if($prev _page< 1){ Echo"Prev |"; }Else{ Echo"$PATH _info? page=$prev _page' > Prev | "; } if($next _page>$p _count){ Echo"Next Page |"; }Else{ Echo"$PATH _info? page=$next _page' > Next | "; } if($page>=$p _count){ EchoThe last page
\ n "
; }
Else
{
Echo"$PATH _info? page=
$p _count' > Last page
\ n "
; } ?>
Upload Files
Second, backstage management
<title>Background processing page</title>
Phperror_reporting(1); if($_files[' Upfile '] [' name '] = =NULL){ Echo"No file choice."; EchoReturns; }Else{ $filepath= "/library/webserver/documents/test/images/"; $tmp _name=$_files[' Upfile '] [' Tmp_name ']; $filename=$filepath.$_files[' Upfile '] [' Name '];//echo $filename; if(Move_uploaded_file($tmp _name,$filename)){ $dataname= "Data.dat"; $myfile=file($dataname); if($myfile[0] = = ""){ $fp=fopen($dataname, "A +"); fwrite($fp, "1| |".$_files[' Upfile '] [' name ']. "| |".$_post["Content"]. "| |".Date(Y year M D Day). " \ n "); fclose($fp); }Else{ $temp=Explode("||",$myfile[0]); $temp[0]++; $fp=fopen($dataname, "R"); $line _has=fread($fp,filesize("$dataname")); fclose($fp); $fp=fopen($dataname, "W"); fwrite($fp,$temp[0]. "| |".$_files[' Upfile '] [' name ']. "| |".$_post["Content"]. "| |".Date("Y year M D Day"). " \ n "); fwrite($fp,"$line _has"); fclose($fp); } Echo""; Echo"The specified file has been uploaded successfully!" "; Echo""; Echo"Point Back"; }Else{ Echo"File Upload failed!" "; } }?>
Third, image upload
Album upload page
Image album upload page
Back to Home
Four, picture view
<title>View pictures</title>
View images.
Php
error_reporting(0
);
if(!
$_get["id"
]){
Echo"No Assign ID."
;
EchoHome
;
Exit
(); }
Else
{ ?> Back Home &
nbsp; $_get[' ID ']?> > Delete picture
Php
$id=
$_get["id"
];
$filename= "Data.dat"
;
$myfile=
file(
$filename
);
$z=
$myfile[0
];
if(
$z== ""
){
Echo"Number of record bars is 0"
; }
Else
{
$temp=
Explode("||",
$myfile[
$z-
$id
]);
Echo"
"." File name: ". $temp [1]. "
"
;
Echo"
$temp [1]. " >
"
;
Echo"
Picture description: ". $temp [2]. "
"
;
Echo"
Upload date: ". $temp [3]. "
"
; } } ?>
V. Delete pictures
<title>Delete a picture</title>
Phperror_reporting(0); if(!$_get["id"]){ Echo"No ID assign."; Echo"
"; EchoHome; Exit(); }Else{ $id=$_get["id"]; $filename= "Data.dat"; $myfile=file($filename); $z=$myfile[0]; if($z==NULL){ Echo"Current number of records: 0"; }Else{ $temp=Explode("||",$myfile[$z-$id]); Print_r($temp); $filepath= "/library/webserver/documents/test/images/"; $imgfile=$filepath.$temp[1]; Echo $imgfile; unlink($imgfile); for($i= 0;$i< ($z-$id);$i++){ $temp 2=Explode("||",$myfile[$i]); $temp 2[0]--; if($temp 2[0]>0) $text 2=$text 2.$temp 2[0]. "| |".$temp 2[1]. "| |".$temp 2[2]. "| |".$temp 2[3]; } for($i=($z-$id+1);$i<$z;$i++){ $text 1=$text 1.$myfile[$i]; } $fp=fopen($filename, "W"); fwrite($fp,$text 2); fwrite($fp,$text 1); fclose($fp); Echo"The specified file has been deleted successfully!" "; EchoHome; } }?>
http://www.bkjia.com/PHPjc/1048764.html www.bkjia.com true http://www.bkjia.com/PHPjc/1048764.html techarticle PHP album feature implementation (including PHP image upload, background management, browse and delete) Tutorial examples, album feature implementation (including PHP image upload, background management, browse and delete) Tutorial examples include five ...