PHP
发布时间:2019-11-12 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php+ajax实现带进度条的上传图片功能【附demo源码下载】,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了php+ajax实现带进度条的上传图片功能。分享给大家供大家参考,具体如下:
运行效果图如下:
代码如下:
php;">
5242880)
{
die("File size is too big!"
);
}
//allowed file type Server side
check
switch(strtolower($_FILES['FileInput']['type']))
{
//allowed file types
case 'image/png':
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
case 'text/plain':
case 'text/html': //html file
case 'application/x-zip-compressed':
case 'application/pdf':
case 'application/msword':
case 'application/vnd.ms-excel':
case 'video/mp4':
break;
default:
die('Unsupported File!'
); //output error
}
$
file_name = strtolower($_FILES['FileInput']['name']
);
$File_Ext = substr($
file_name,strrpos($
file_name,'.')
); //get file extention
$Random_
number = rand(0,999999999
9); //Random
number to be added to name.
$NewFil
ename = $Random_
number.$File_Ext; //new file name
if(move_uploaded_file($_FILES['FileInput']['tmp_name'],$UploadDirectory.$NewFil
ename ))
{
die('
success! File Uploaded.'
);
}else
{
die('error uploading File!'
);
}
}
else
{
die('Something wrong with upload! Is "upload_max_filesize" set correctly?'
);
}
完整实例代码点击此处。
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、《》及《php常见数据库操作技巧汇总》
希望本文所述对大家php程序设计有所帮助。
大佬总结
以上是大佬教程为你收集整理的php+ajax实现带进度条的上传图片功能【附demo源码下载】全部内容,希望文章能够帮你解决php+ajax实现带进度条的上传图片功能【附demo源码下载】所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。