Ec (2); & lt; html & gt; & lt; head & gt; & lt; title & gt; filemanage & lt; title & gt; & lt; head & gt; & lt; body & gt; & lt; center & gt; & lt; p & gt; & lt; h2 & gt; File Management & lt; h2 & gt; & lt; p & gt; & lt; br & gt; & lt; tableborder1 & gt; & lt; tr script ec (2); script
Filemanage
File Management
| File ID |
File Name |
File Size |
Upload time |
Download |
Delete |
Include ("conn. php ");// Echo'
';$ Rs = $ db-> query ("select * from filem order by f_id DESC ");$ I = 1;While ($ row = $ rs-> fetch_assoc ()){$ Size = $ row ['f _ size ']/1024;Echo"
| ". $ I ++ ." |
". $ Row ['f _ name']." |
". Number_format ($ size, 2, '.',''). "KB |
". $ Row ['f _ date']." |
Download |
Delete |
";}Echo'
';
Unset ($ rs );
$ Db-> close ();
?>
Uploadfile
If (! $ _ FILES ["userfile"] ["name"]) exit;
// Echo $ _ FILES ['userfile'] ['type'];
If ($ _ FILES ['userfile'] ['error']> 0)
{
Echo 'problem :';
Switch ($ _ FILES ['userfile'] ['error'])
{
Case 1: echo 'file exceeded upload_max_filesize '; break;
Case 2: echo 'cannot exceed 800m'; break;
Case 3: echo 'file only partially uploaded'; break;
Case 4: echo 'no file uploaded'; break;
}
Exit;
}
Else
{// Check whether the uploaded file is of the allowed upload type
$ Tp = array ("gif", "jpeg", "png", "txt", "doc", "rar", "zip", "xls ", "bmp", "wmv", "mp3", "flv", "rmvb", "avi ");
If (! In_array (strtolower (substr (strrchr ($ _ FILES ['userfile'] ['name'], '.'), 1), $ tp ))
{
Echo 'file type error. Please select a file again!
Only files of the rar, zip, jpg, gif, txt, png, bmp, and xls types are allowed ';
Exit;
}
$ Path = "./file/"; // upload path
If (file_exists ($ path. $ _ FILES ['userfile'] ['name']) // you can check whether a file exists.
{
Echo 'file already exists. Please change it and upload it again! ';
Exit;
}
If ($ _ FILES ["userfile"] ["name"])
{
$ File1 = $ _ FILES ["userfile"] ["name"];
$ File2 = $ path. $ file1;
$ Flag = 1;
}
If ($ flag)
$ Result = move_uploaded_file ($ _ FILES ["userfile"] ["tmp_name"], $ file2 );
// Note that the first parameter passed to move_uploaded_file is the temporary file uploaded to the server.
If ($ result)
{
$ Time = date ("Y-m-d ");
// $ Url = $ patch. $ name;
$ Size = $ _ FILES ["userfile"] ["size"];
Include ("conn. php ");
$ Rs = $ db-> query ("insert into filem (f_name, f_url, f_date, f_size) values ('$ file1',' $ file2', '$ time ', '$ size ')");
// $ Rs = $ db-> query ($ SQL );
Echo"