php upload picture
来源:互联网 发布:暴雪游戏平台 for mac 编辑:程序博客网 时间:2024/04/28 20:47
/** forandever@ 2005/03/14
* 图片上传,默认使用原来文件名
* uploaddir:服务器路径
* is_over:允许覆盖
* $srcfile:file域的名称
* $new_name:只要名称,不带后缀
* return array
*/
function uploadPic($uploaddir,$file_src,$new_name,$is_over=0)
{
$file_tmp = GetImageSize($_FILES[$file_src]['tmp_name']);
/* type */
if( $file_tmp['mime'] != 'image/gif'
&& $file_tmp['mime'] != 'image/jpg'
&& $file_tmp['mime'] != 'image/jpeg'
&& $file_tmp['mime'] != 'image/png'
&& $file_tmp['application/x-shockwave-flash']
){
exit('文件格式不合要求,只能上传gif,jpg/jpeg,png格式!');
}
else
{
/* width*height */
$file_width = $file_tmp['0'];
$file_height = $file_tmp['1'];
}
/* size */
$filesize = sizecount($_FILES[$file_src]['size']);
/* ext */
$ext = substr(strrchr(trim(strtolower($_FILES[$file_src]['name'])),"."),1);
/* name */
if($new_name == "")
{
$last_name = $_FILES[$file_src]['name'];
}
else
{
$last_name = $new_name.".".$ext;
}
/* array */
$pic_arr = array(
newname => $last_name,
lastname=> $_FILES[$file_src]['name'],
width => $file_width,
height => $file_height,
size => $filesize,
ext => $ext,
mime => $file_tmp['mime']
);
/* check database */
$pname = $pic_arr[newname];
$p_showname = $pic_arr[lastname];
$pwidth = $pic_arr[width];
$pheight = $pic_arr[height];
$psize = $pic_arr[size];
$ext = $pic_arr[ext];
$que = "select count(pid) from pic_view where p_showname='$p_showname' and pwidth='$pwidth' and pheight='$pheight' and psize='$psize'";
$res = mysql_query($que);
if(0 <> mysql_num_rows($res))
{
exit("对不起!服务器上面已经存在相同文件!");
}
/* if exists */
if($is_over == 0)
{
if(file_exists($uploaddir.$_FILES[$file_src]['name']))
{
exit("你所上传的文件已经存在!");
}
else
{
if(move_uploaded_file($_FILES[$file_src]['tmp_name'],$uploaddir.$last_name))
{
Return $pic_arr;
}
}
}
else
{
if(move_uploaded_file($_FILES[$file_src]['tmp_name'],$uploaddir.$last_name))
{
Return $pic_arr;
}
}
}
- php upload picture
- picture upload view and html2canvas
- PHP upload
- upload.php
- PHP UPLOAD FILE
- PHP File Upload
- PHP File Upload
- php upload file
- upload.php --->文件上传
- php upload 文件类型 excel
- File Upload PHP
- 原生php upload
- 文件上传类--upload.php
- Secure File Upload with PHP
- PHP 文件上传类upload
- PHP file Upload 错误类型
- upload?
- upload
- debian英文环境中中文输入
- oracle基本操作语句
- php格式化金钱函数
- Modbus
- 图解各种数据库数据源(ODBC)配置
- php upload picture
- Java Web Start 学习
- 编译器错误信息: CS0016: 未能写入输出文件,../Temporary ASP.NET Files/WebApp8.dll”--拒绝访问
- Socket开发之通讯协议及处理
- 多数求职者只问岗位不“谋”财
- 各国招聘人才的新奇招数
- 快讯:中国个人所得税起征点有望上调至二千元
- 信产部:手机单向收费不到时候
- TThread —— 线程类详解