php无刷新文件上传代码

?phpif (isset($_GET[‘action’]) $_GET[‘action’]==’update’){
//update notice data //上传文件 require_once(upload_class.php); $f =
new Upload( $savepath, $fileFormat, $maxsize, $overwrite); if
(!$f-run(‘img’)) {//下面的img是Form中上传文件的input的名字 echo
$f-errmsg();
//这里只能传递最后一个出错的信息,详细的信息在$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 xmlns= 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/scriptscript src={{$baseurl}}/js/jquery.js
type=text/javascript/scriptscript src={{$baseurl}}/js/Forms.js
type=text/javascript/scriptscript src={{$baseurl}}/js/FormValid.js
type=text/javascript/scriptscript type=text/javascript FormValid.succeed
= function () {
$.post(./article.php?action=update,$.getForms(update),function (msg){
alert(msg); if(msg==更新公告成功) { location.href(./article.php); }
//location.href({{$baseurl}}/index.php); }); return false; }function
file_addupload(type){ //负责增加图片输入框 var ptext=”;
ptext=$(#+type+_more).html()+br /input type=’file’ name=’+type+[]’
class=’input’ /;
$(#+type+_more).html(ptext);}/scripttitle发布文章–编辑页面/title/headbody
table width=99% border=0 cellpadding=0 cellspacing=1 class=install tr td
colspan=2 class=title编辑文章内容/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文章标题:/td
td class=rightinput type=text id=title name=article_title
value={{$article[article].title}} class=input size=35 valid=required
errmsg=文章标题不能为空 //td /tr tr td class=left发布IP:/td td
class=rightinput type=text id=ip value={{$article[article].ip}}
name=ip class=input readonly //td /tr tr td class=left作者:/td td
class=rightinput type=text id=author name=article_validtime
value={{$article[article].author}} valid=required
errmsg=请输入文章作者 //td /tr tr td class=left分类:/td td
class=rightselect name=’sort'{{html_options options=$sort_options
selected=$article[article].sort }}/select/td /tr tr td
class=left来源:/td td class=rightinput type=text id=comes name=comes
value={{$article[article].comes}} class=input//td /tr tr td
class=left是否置顶:/td td class=right{{html_radios name=’is_top’
options=$is_top_radios checked=$article[article].is_top separator=’
‘ _note=’是否置顶#124;radio#124;1=是,0=否’ }}/td /tr tr td
class=left内容:/td td class=right{{$editor}}/td /tr tr td
class=left图片上传:/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文件上传:/td td
class=rightinput 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=保存 / input type=button
name=article_return value=返回 class=button
onclick=javascript:location.href(‘./article.php’); //td /tr /form
{{/section}}/tableiframe name=upload_iframe style=width: 400px; height:
100px; display: none;/iframe/body/html