<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_45066"> <div class="blockcode"> <div id="code_uL0"><ol> <li> <li><?php<li>/**<li>* php 文件上传<li>* 2013-11-30<li>*/<li>if($_POST[sub]){<li>if(is_uploaded_file($_FILES[file][tmp_name])){//判断是否取到临时文件,并保存php内部。返回值为1为真。<li>$file=$_FILES[file];<li>print_r($file); // bbs.it-home.org<li>$name=$file[name];<li>$tmp=$file[tmp_name];<li>$size=$file[size];<li>$error=$file[error];<li>$type=$file[type];<li>}<li>switch($type){<li> case 'image/pjpeg' : $ok=1;<li> break;<li> case 'image/jpeg' : $ok=1;<li> break;<li> case 'image/gif' : $ok=1;<li> break;<li> case 'image/png' : $ok=1;<li> break;<li>}<li>if($error=='0'&& $ok==1){<li>move_uploaded_file($tmp,'upfile/'.$name);<li>echo "上传成功 ";<li>}else{<li>echo "上传失败";<li>}<li>}<li> ?></li> <li><form name="form" method="post" enctype="multipart/form-data" action=""></li> <li><input name="file" type="file" /></li> <li><input name="sub" type="submit" value="上传" /></li> <li></form></li> </ol></div> <em onclick="copycode($('code_uL0'));">复制代码</em> </div> </td></tr></table> <div id="comment_45066" class="cm"> </div> <div id="post_rate_div_45066"></div> <br><br>