PHP Simple File Manager--php Classic Instance

Source: Internet
Author: User
Tags rtrim

'Utf-8'/> PHP//define the directory you want to view$dir ="/"; //determine if $_get[' a '] has passed the value to prevent notice errors            if(Isset ($_get['a'])){                //choose to decide what action to take                Switch($_get['a']){                     Case 'creat':                        //New File$filename =$_post["filename"]; $filename=rtrim ($dir,"/")."/". $filename; //write to file write an empty stringFile_put_contents ($filename,"");  Break;  Case 'del':                        //Deleting FilesUnlink ($_get['filename']);  Break;  Case 'Update':                        //Modify a fileFile_put_contents ($_post['filename'],$_post['content']); Echo"Modification succeeded"; Header ("refresh:1;url=index.php");  Break; }            }                    ?> <center> 'index.php?a=creat'Method='Post'>File:<input type='text'Name='filename'/> <input type='Submit'Value='New'/> </form> <table border='1'Width=' the'cellpadding='5'cellspacing='0'> <tr> <th> file name </th> <th> type </th> <th> size </th> <th> creation time </th> <th> action </th > </tr> <?PHP//Traverse Directory$DD =Opendir ($dir);  while(false!== ($f =Readdir ($DD))) {                        //Filter Point                        if($f = ="."|| $f = =".."){                            Continue; }                        //Spell Path$file =rtrim ($dir,"/")."/". $f; //prevent Chinese garbled characters$f 2=iconv ("gb2312","Utf-8", $f); Echo"<tr>"; Echo"<td>{$f 2}</td>"; Echo"<td>". FileType ($file)."</td>"; Echo"<td>". FileSize ($file)."</td>"; Echo"<td>". Filectime ($file)."</td>"; Echo"<td align= ' center ' ><a href='index.php?a=edit&filename={$file}'> Modify </a>| <a href='index.php?a=del&filename={$file}'> Delete </a> </td>";Echo"</tr>"; }                ?> </table> <?PHPif(Isset ($_get['a']) && $_get['a']=='Edit') {echo""; Echo"<form action= ' index.php?a=update ' method= ' post ' >"; Echo"file name: <input type= ' text ' name= ' filename ' readonly value= ' {$_get[' filename '} '/>"; Echo"<br/><br/>"; Echo"<textarea name= ' content ' rows= ' 5 ' cols= ' >". file_get_contents ($_get['filename'])."</textarea>"; Echo"<br/><br/>"; Echo"<input type= ' Submit ' value= ' Save changes '/>"; Echo"</form>"; }                        ?> </center> </body>

PHP Simple File Manager--php Classic Instance

PHP Simple File Manager--php Classic Instance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.