[Html]
<Form name = "myform" id = "myform" class = "registerform" method = "post" action = "? Action = add ">
<Input name = "pic1" id = "pic1" type = "text" style = "width: 293px;"/>
<Input name = "" type = "button" class = "button02" onClick = "window. open ('admin _ upload. php? FormName = myform & editName = pic1 & upPath =/attached ', '', 'status = no, scrollbars = no, top = 100, left = 210, width = 420, height = 165 ') "/>
</Form>
Admin_upfile.php
[Php]
<Html>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<? Php
Date_default_timezone_set ('prc ');
// Upload $ upsize here to determine the size of the uploaded file
$ Uppath = isset ($ _ REQUEST ["upPath"])? $ _ REQUEST ["upPath"]: "/attached/"; // File Upload path
$ FormName = isset ($ _ REQUEST ["formName"])? $ _ REQUEST ["formName"]: "myform"; // upload the Name Of the Form in the edit box of the previous page.
$ EditName = isset ($ _ REQUEST ["editName"])? $ _ REQUEST ["editName"]: $ _ REQUEST ["editName"]; // The Name Of The edit box on the upload page.
// Convert the root directory path
If (strpos ($ uppath, "/") = 0 ){
$ I = 0;
$ Thpath = $ _ SERVER ["SCRIPT_NAME"];
$ Thpath = substr ($ thpath, 1, strlen ($ thpath ));
While (strripos ($ thpath ,"/")! = False ){
$ Thpath = substr ($ thpath, strpos ($ thpath, "/") + 1, strlen ($ thpath ));
$ I = ++ $ I;
}
$ Pp = "";
For ($ j = 0; $ j <$ I; ++ $ j ){
$ Pp. = "../";
}
$ Uppaths = $ pp. substr ($ uppath, 1, strlen ($ thpath ));
}
$ Filename = date ("y-m-d ");
If (is_dir ($ uppaths. $ filename )! = TRUE)
Mkdir ($ uppaths. $ filename, 0777 );
// If (is_dir ($ filename. "/". $ ctime )! = TRUE) mkdir ($ filename. "/". $ ctime, 0777 );
$ F = $ _ FILES ['file1'];
If ($ f ["type"]! = "Image/gif" & $ f ["type"]! = "Image/pjpeg" & $ f ["type"]! = "Image/jpeg" & $ f ["type"]! = "Image/x-png "){
Echo "<script> alert ('only files in image format upload'); window. close () </script> ";
// Echo $ f ['type'];
Return false;
}
// Obtain the file extension
$ Temp_arr = explode (".", $ f ["name"]);
$ File_ext = array_pop ($ temp_arr );
$ File_ext = trim ($ file_ext );
$ File_ext = strtolower ($ file_ext );
// New file name
$ New_file_name = md5 (date ("YmdHis"). '.'. $ file_ext;
// $ New_file_name = md5 (date ("YmdHis"). '_'. rand (10000,999 99). '.'. $ file_ext;
$ Dest = $ uppaths. $ filename. "/". date ("ymdhis"). "_". $ new_file_name; // set the file name to the date plus the file name to avoid repeated upload Directories
$ Dest1 = $ uppath. $ filename. "/". date ("ymdhis"). "_". $ new_file_name; // set the file name to the date plus the file name to avoid duplication
$ R = move_uploaded_file ($ f ['tmp _ name'], $ dest );
If ($ f ['SIZE']> 0 ){
Echo "<script> encode your opener.doc ument.". $ formName. ".". $ editName. ". value = '". $ dest1. "' </script> ";
Echo "<script> alert ('image uploaded successfully'); window. close () </script> ";
}
?>
</Html>
Admin_upload.php
[Php]
<Html>
<Head>
<Title> upload images </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<? Php
$ Uppath = isset ($ _ REQUEST ["upPath"])? $ _ REQUEST ["upPath"]. "/": "/attached/"; // File Upload path
$ FormName = isset ($ _ REQUEST ["formName"])? $ _ REQUEST ["formName"]: "myform"; // upload the Name Of the Form in the edit box of the previous page.
$ EditName = isset ($ _ REQUEST ["editName"])? $ _ REQUEST ["editName"]: $ _ REQUEST ["editName"]; // The Name Of The edit box on the upload page.
?>
<Script language = "javascript">
<! --
Function mysub ()
{
Esave. style. visibility = "visible ";
}
-->
</Script>
<Style type = "text/css">
<! --
. STYLE2 {
Font-size: 12pt
}
. STYLE3 {
Font-size: 14pt
}
-->
</Style>
</Head>
<Body oncontextmenu = 'Return false' onselectstart = "return false" oncopy = "return false;" oncut = "return false;">
<Form name = "form1" method = "post" action = "admin_upfile.php" enctype = "multipart/form-data">
<Div id = "esave" style = "position: absolute; top: 18px; left: 40px; z-index: 10; visibility: hidden">
<Table width = 340 BORDER = 0 CELLSPACING = 0 CELLPADDING = 0>
<TR>
<Td width = 20?> </Td>
<TD bgcolor = # ff0000 width = "60%"> <table width = 100% height = 120 BORDER = 0 CELLSPACING = 1 CELLPADDING = 0>
<TR>
<Td bgcolor = # ffffff align = center> <font color = red> uploading files. Please wait... </font> </td>
</Tr>
</Table> </td>
<Td width = 20?> </Td>
</Tr>
</Table>
</Div>
<Table class = "Border" width = "100%" border = "0" height = "100%" align = "center" cellpadding = "3" cellspacing = "1" bgcolor =" # FFFFFF ">
<Tr>
<Td align = "center" class = "title" height = "30"> <B> <span class = "style2 STYLE3"> Image Upload </span>
<Input type = "hidden" name = "upPath" value = "<? = $ Uppath?> ">
<Input type = "hidden" name = "editName" value = "<? = $ EditName?> ">
<Input type = "hidden" name = "formName" value = "<? = $ FormName?> ">
</B> </td>
</Tr>
<Tr bgcolor = "# E8F1FF">
<Td height = "94" align = "center" id = "upid"> select a file:
<Input type = "file" name = "file1" size = "20" class = "tx1" value = "">
<Input type = "submit" name = "Submit" value = "Start upload" class = "button" onClick = "mysub ();">
<Br> </td>
</Tr>
</Table>
</Form>
</Body>
</Html>