<? PHP
Require dirname (_ file _). '/include/Inc. php ';
Require dirname (_ file _). '/include/sys_session.php ';
Require dirname (_ file _). '/include/upload_fun.php ';
$ Uptypes = array (
'Image/jpg ',
'Image/JPEG ',
'Image/PNG ',
'Image/pjpeg ',
'Image/gif ',
'Image/BMP ',
'Image/X-PNG'
);
$ _ Filepaths = replace_text ($ _ post ["filepaths"]);
$ _ Editname = replace_text ($ _ post ["editname"]);
$ _ Formname = replace_text ($ _ post ["formname"]);
$ _ Ppid = replace_text ($ _ post ["ppid"]);
$ _ Act = replace_text ($ _ post ["act"]);
$ Max_file_size = 2000000; // size limit of uploaded files, in bytes
$ Destination_folder = $ _ filepaths; // File Upload path
$ Watermark = 1; // whether to add a watermark. (1 indicates adding a watermark. Otherwise, no watermark is added );
$ Watertype = "IMG"; // IMG indicates adding a watermark as an image and text indicates adding a watermark as a text.
$ Waterposition = 7; // (1 indicates the lower left corner, 2 indicates the lower right corner, 3 indicates the upper left corner, 4 indicates the upper right corner, and 5 indicates the center );
$ Waterstring = "0917e.com"; // watermark string
$ Textcolor = ""; // watermark color
$ Fonttype = ""; // watermark font
$ Waterimg = "images/logo.png"; // watermark image
$ Cls_ftp = 0;
If ($ _ act = 'uploadfile ')
{
If (! Is_uploaded_file ($ _ FILES ["file1"] [tmp_name])
// Whether a file exists
{
Echo "the image does not exist! ";
Exit;
}
$ File = $ _ FILES ["file1"];
If ($ max_file_size <$ file ["size"])
// Check the file size
{
Echo "the file is too large! ";
Exit;
}
If (! In_array ($ file ["type"], $ uptypes ))
// Check the file type
{
Echo "file type does not match! ". $ File [" type "];
Exit;
}
If (! File_exists ($ destination_folder ))
{
Mkdir ($ destination_folder );
}
$ Filename = $ file ["tmp_name"];
$ Image_size = getimagesize ($ filename );
$ Pinfo = pathinfo ($ file ["name"]);
$ FTYPE = $ pinfo ['extension'];
$ Destination = $ destination_folder.time (). ".". $ FTYPE;
If (file_exists ($ destination) & $ overwrite! = True)
{
Echo "a file with the same name already exists ";
Exit;
}
If (! Move_uploaded_file ($ filename, $ destination ))
{
Echo "An error occurred while moving the file ";
Exit;
}
$ Pinfo = pathinfo ($ destination );
$ Fname = $ pinfo [basename];
// Echo "<font color = Red> successfully uploaded </font> <br> file name: <font color = blue> ". $ destination_folder. $ fname. "</font> <br> ";
// Echo "width:". $ image_size [0];
// Echo "Length:". $ image_size [1];
// Echo "<br> size:". $ file ["size"]. "bytes ";
If ($ watermark = 1 ){
Setwater ($ destination_folder. $ fname, $ waterimg, $ waterstring, $ textcolor, $ waterposition, $ fonttype, $ watertype );
}
If ($ cls_ftp = 1 ){
$ Picname = $ destination_folder. $ fname;
$ Cls_ftp_path = $ fname;
$ Ftp_server = "FTP address ";
$ Con = ftp_connect ($ ftp_server );
Ftp_login ($ con, "username", "password ");
$ Tempstate = ftp_put ($ con, $ cls_ftp_path, $ picname, ftp_binary); // upload files in binary mode
If ($ tempstate ){
// Unlink can also be used to delete images on the WWW server.
Echo "<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0'> ";
Echo "<tr> ";
Echo "<TD valign = 'middle' align = 'center'> ";
Echo (" ");
Echo ("<span style = 'margin: auto; font-family: verdana, Geneva, sans-serif; font-size: 16px; color: #900; '> <br> upload succeeded. do not modify the uploaded image address </span> ");
Echo "</TD> ";
Echo "</tr> ";
Echo "</table> ";
} Else {
Echo "Upload Failed ";
Exit ();
}
Ftp_quit ($ con );//
}
Echo "<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0'> ";
Echo "<tr> ";
Echo "<TD valign = 'middle' align = 'center'> ";
Echo (" ");
Echo ("<span style = 'margin: auto; font-family: verdana, Geneva, sans-serif; font-size: 16px; color: #900; '> <br> upload succeeded. do not modify the uploaded image address </span> ");
Echo "</TD> ";
Echo "</tr> ";
Echo "</table> ";
}
_ Close ();
?>
<Script language = "JavaScript">
VaR DG = frameelement. lhgdg;
Window. onload = function ()
{
Dg.curwin.doc ument. getelementbyid ("pic1"). value = ("<? PHP echo $ fname?> ");
DG. addbtn ('close', 'upload successful ', dg. Cancel );
DG. redialogsize (450,200 );
}
</SCRIPT>