Usage:
1. First create the uploadfile directory in the root directory
2. "Value" and "graph": this is used to upload the image to the parent window. Value, which is the file name and can be used for input. Graph, which is an image and used for the editor. When using this function, enter the ID value of the parent window in the text box before "value. I can assign values normally when the program is popped up at the usage layer.
3. Multiple files can be uploaded. If the target directory contains the same file, the file name will be renamed "nw..jpg", which is the same as that of "FCKeditor".
Test Environment: apache2.2.14 + PHP5.3 + windowswww.111cn.net
*/
The code is as follows: |
Copy code |
Header ("Content-type: text/html; charset = UTF-8 "); Define ("ROOT", str_ireplace ('/waityou /'. basename (_ FILE _), '', str_ireplace (" \ ","/",__ FILE __))); Define ("UploadFolder", "/uploadfile/"); // upload the root directory Define ("_ d", $ _ SERVER ['document _ root']); Define ("AllowUploadType ", "gif | jpg | png | txt | doc | xls | ppt | pdf | rar | zip | 7z | chm | mp3 | mp4 | mpg | mpeg | flv | swf "); // supported Upload types Define ("MaxUploadSize", @ ini_get ('upload _ max_filesize ')); $ Act = empty ($ _ GET ['act '])? '': $ _ GET ['act '];
If ($ act = ""){ Html_header (); } Elseif ($ act = 'left '){ Left (); } Elseif ($ act = 'right '){ If (! Empty ($ _ POST ['upfolder']) { Upload_file (); exit; } $ Dir = empty ($ _ GET ['Folder'])? '': $ _ GET ['Folder']; If ($ dir = ''){ Right (UploadFolder ); } Else { $ Del_file = empty ($ _ GET ['Del _ file'])? '': $ _ GET ['Del _ file']; If ($ del_file = ''){ Open_folder ($ dir ); } Else { Delete_file ($ del_file ); } } } |