首页 > Web开发 > 详细

php文件上传

时间:2015-09-11 01:27:15      阅读:250      评论:0      收藏:0      [点我收藏+]

html

照片:<input type="file" id=‘photo‘ name="photo" /></span>
    <input type="submit" id=‘submit‘ name="submit" value="上传文件" />
        
</form>
<input type="button" id="btnOk" value="注册" />
<iframe name="frm" style="display:none" ></iframe> 

php

if(isset($_POST[‘submit‘])){
    $extname=strrchr($_FILES[‘photo‘][‘name‘],‘.‘ );//取文件扩展名
    $filename=time().$extname;                      //获取新的文件名
    copy($_FILES[‘photo‘][‘tmp_name‘], ‘upload/‘.$filename); //拷贝文件到指定目录(可指定名称)
}

strrchr截取字符串

php文件上传

原文:http://www.cnblogs.com/hhfhmf/p/4799722.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!