PHP No refresh File upload code
Last Update:2017-01-13
Source: Internet
Author: User
<?php
if (Isset ($_get[' action ')) && $_get[' action ']== ' update ')
{
Update notice data
Uploading files
Require_once ("upload_class.php");
$f = new Upload ($savepath, $fileFormat, $maxsize, $overwrite);
if (! $f->run (' img '))
{//The following IMG is the name of the input for the file uploaded in form
echo $f->errmsg (); Only the last error message can be delivered here, and the detailed information is available in $f->getinfo ().
Print_r ($f->returnarray);
}
echo "
<script src= "". __filename__. /js/jquery.js "type=" Text/javascript "></script>
<script>
var ptext= ';
Ptext= "OK";
Alert ($ (' #img_view '). html ());
parent.$ (' #img_view '). HTML (ptext);
</script> ";
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<link href= "{{$tempurl}}/admin.css" rel= "stylesheet" type= "Text/css"/>
<link href= "{{$baseurl}}/js/calendar/default/datepicker.css" rel= "stylesheet" type= "Text/css"/>
<script src= "{{$baseurl}}/js/calendar/wdatepicker.js" type= "Text/javascript" ></script>
<script src= "{{$baseurl}}/js/jquery.js" type= "Text/javascript" ></script>
<script src= "{{$baseurl}}/js/forms.js" type= "Text/javascript" ></script>
<script src= "{{$baseurl}}/js/formvalid.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >
Formvalid.succeed = function () {
$.post ("./article.php?action=update", $.getforms ("Update"), function (msg) {
Alert (msg);
if (msg== "update announcement succeeded")
{
Location.href ("./article.php");
}
Location.href ("{{$baseurl}}/index.php");
});
return false;
}
function File_addupload (type)
{
Responsible for adding picture input box
var ptext= ';
ptext=$ ("#" +type+ "_more"). HTML () + "<br/><input type= ' file ' name= '" "+type+" [] ' class= ' input '/> ';
$ ("#" +type+ "_more"). HTML (ptext);
}
</script>
<title> post-edit page </title>
<body >
<table width= "99%" border= "0" cellpadding= "0" cellspacing= "1" class= "Install" >
<tr>
<TD colspan= "2" class= "title" > Edit article Content </td>
</tr>
{{section name=article loop= $article}}
<form action= "./article.php?action=update" method= "POST" name= "Update" enctype= "Multipart/form-data" target= " Upload_iframe ">
<input type= "hidden" name= "article_id" value= "{{$id}}" >
<tr>
<TD class= "left" > article title:</td>
<TD class= "right" ><input type= "text" id= "title" Name= "Article_title" value= "{{$article [article].title}}}" class= "Input" size= "valid=" required "errmsg=" article title can not be empty "/></td>
</tr>
<tr>
<TD class= "Left" > Release ip:</td>
<TD class= "right" ><input type= "text" id= "IP" value= "{{$article [Article].ip}}" Name= "IP" class= "input" ReadOnly/></td>
</tr>
<tr>
<TD class= "Left" > author:</td>
<TD class= "right" ><input type= "text id=" author "name=" Article_validtime "value=" {{{$article [Article]. Author}} "valid=" required "errmsg=" Please enter article author "/></td>"
</tr>
<tr>
<TD class= "left" > Classification:</td>
<TD class= "right" ><select name= ' sort ' >
{{html_options options= $sort _options selected= $article [Article].sort}}}
</select></td>
</tr>
<tr>
<TD class= "Left" > Source:</td>
<TD class= "right" ><input type= "text id=" comes "name=" comes "value=" {{$article [article].comes}} "class=" Input "/></td>
</tr>
<tr>
<TD class= "Left" > is top:</td>
<TD class= "right" >{{html_radios name= ' is_top ' options= $is _top_radios checked= $article [article].is_top Separator= ' _note= ' is top & #124;radio& #124;1=> is,0=> no '}}</td>
</tr>
<tr>
<TD class= "Left" > Content:</td>
<TD class= "Right" >{{$editor}}</td>
</tr>
<tr>
<TD class= "left" > Picture upload:</td>
<TD class= "Right" >
<span id= "Img_view" >
<input type= "File" Name= "img[]" class= "input"/>
<a href= "#" onclick= "File_addupload (' img ')" >++</a>
<span id= "Img_more" ></span>
</span>
</tr>
<tr>
<TD class= "Left" > File upload:</td>
<TD class= "right" ><input type= "file" Name= "file[]" class= "input"/>
<a href= "#" onclick= "file_addupload (' file ')" >++</a>
<span id= "File_more" ></span>
</td>
</tr>
<tr>
<TD colspan= "2" class= "page" style= "Text-align:center;" ><input type= "Submit" name= "Submit" class= "button" value= "Save"/> <input type= "button" Name= "Article_return "Value=" returns "Class=" button "onclick=" Javascript:location.href ('./article.php '); "/></td>
</tr>
</form>
{{/section}}}
</table>
<iframe name= "Upload_iframe" style= "width:400px; height:100px; Display:none; " >
</iframe>
</body>