加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php ajax无刷新文件上传实例

发布时间:2020-12-13 05:18:00 所属栏目:PHP教程 来源:网络整理
导读:本实例有两个文件: 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 fold

本实例有两个文件:

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";

}

?>

(编辑:李大同)

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

    推荐文章
      热点阅读