加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php ajax无刷新文件上传实例

发布时间:2020-05-25 01:02:28 所属栏目:PHP 来源:互联网
导读:看了很多网站关于php无刷新上传文件的实例,都是从其他网站转载的同一篇文章,而且代码有明显的错误。本实例100%可以运行,对需要此功能的朋友来说,一定是一个不错的参考实例。

本实例有两个文件:

upload_form.html:

HTML5 File Upload Progress Bar Tutorial

file_upload_parser.php:

$fileName = $_FILES["file1"]["name"]; // The file name

$fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder

$fileType = $_FILES["file1"]["type"]; // The type of file it is

$fileSize = $_FILES["file1"]["size"]; // File size in bytes

$fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true

if (!$fileTmpLoc) { // if file not chosen

echo "ERROR: Please browse for a file before clicking the upload button.";

exit();

}

if(move_uploaded_file($fileTmpLoc,"test_uploads/$fileName")){

echo "$fileName upload is complete";

} else {

echo "move_uploaded_file function failed";

}

?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读