上传图片到PHP服务器
2024-08-31 03:08:49
test_picture = function() {
api.getPicture({
sourceType: 'library',
encodingType: 'png',
mediaValue: 'pic',
destinationType: 'url',
allowEdit: true,
//quality: ,
//targetWidth:,
//targetHeight:,
saveToPhotoAlbum: false
}, function(ret, err){
if (ret) {
api.ajax({
timeout : ,
method : 'post',
url : 'http://192.168.1.121/picture.php',
data : {
files:{upfile : ret.data},
},
dataType : 'json',
}, function(ret, err) {
api.hideProgress();
alert(JSON.stringify(ret));
});
} else {
api.alert({msg:err.msg});
};
});
}; PHP接收图片
<?php
function getname($exname){
$dir = "./uploadfile/";
$i=;
if(!is_dir($dir)){
mkdir($dir,);
}
while(true){
if(!is_file($dir.$i.".".$exname)){
$name=$i.".".$exname;
break;
}
$i++;
}
return $dir.$name;
} $exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+))); $uploadfile = getname($exname); if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) { echo "<h2><font color=#ff0000>文件上传成功!</font></h2><br><br>"; } else { echo "<h2><font color=#ff0000>文件上传失败!</font></h2><br><br>"; }
?>
最新文章
- 喜马拉雅音频下载器 V1.2 支持专辑批量下载 喜马拉雅mp3下载导出 喜马拉雅下载器
- Texture tiling and swizzling
- window安装jekyll
- 解决IIS7.0服务和用户上传的文件分别部署在不同的电脑上时,解决权限的问题
- 如何解决phpcms后台验证码不显示的问题
- 在启动dubbo框架时报错。Unable to connect to zookeeper server within timeout: 5000
- linux下IM server搭建
- div与>;div区别小结
- Web Development Terms
- jstl中添加自定义的函数
- mysql免安装版使用
- 非滤波单目视觉slam笔记1
- 【BZOJ4805】欧拉函数求和(杜教筛)
- Springboot整合log4j2【详细步骤】
- LeetCode(41)-Rectangle Area
- codeForces 472D 最小生成树
- 系列文章|OKR与敏捷(三):赋予团队自主权
- 查看macOS下正在使用的zsh
- 【MySQL】常用监控指标及监控方法
- Unable to convert MySQL date/time value to System.DateTime问题解决方案