上传图片到PHP服务器
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>";
}
?>
上传图片到PHP服务器的更多相关文章
- kindeditor修改图片上传路径-使用webapi上传图片到图片服务器
kindeditor是一个非常好用的富文本编辑器,它的简单使用我就不再介绍了. 在这里我着重介绍一些使用kindeditor修改图片上传路径并通过webapi上传图片到图片服务器的方案. 因为我使用的 ...
- kindeditor扩展粘贴图片功能&修改图片上传路径并通过webapi上传图片到图片服务器
前言 kindeditor是一个非常好用的富文本编辑器,它的简单使用我就不再介绍了. 而kindeditor却对图片的处理不够理想. 本篇博文需要解决的问题有两个: kindeditor扩展粘贴图片功 ...
- vue中使用vue-quill-editor及上传图片到自己服务器
第一步,下载依赖 cnpm install vue-quill-editor --save 第二步,再main.js里引入组件(我这里是全局注册) // 富文本编辑器 import VueQuillE ...
- kindeditor扩展粘贴截图功能&修改图片上传路径并通过webapi上传图片到图片服务器
前言 kindeditor是一个非常好用的富文本编辑器,它的简单使用我就不再介绍了. 而kindeditor却对图片的处理不够理想. 本篇博文需要解决的问题有两个: kindeditor扩展粘贴图片功 ...
- 上传图片流到服务器(AFN方法) (多张图片)(图片流)
上传图片流到服务器(AFN方法) (多张图片)(图片流) 第一步//获取图片 UIAlertController *actionSheet = [UIAlertController alertCo ...
- html+php上传图片文件到服务器
html+php上传图片文件到服务器 一.html代码 <body> <form action="" method="post" enctyp ...
- qt5 上传图片到http服务器
转载请注明出处:http://www.cnblogs.com/dachen408/p/8185060.html qt5 上传图片到http服务器,亲测可以用,qt5.8+vs2015,直接上码; 头文 ...
- MVC异步上传图片到本地/服务器
这两天朋友问我,有没有异步上传图片到本地/服务器这种demo,他有用, 我就想,好吧, 那刚好周末了,整理一套出来. 主要用到的是jquery uploadify 这个juqery的插件 ,可以无刷新 ...
- php工作笔记1-数组常用方法总结,二维数组的去重,上传图片到oss服务器
1.二维数组去重,生成二维数组 private function array_unique_fb($array2D){ $data = array(); foreach($array2D as $k ...
- ios客户端base64上传图片到java服务器遇到的问题
由于base64位包含了“+”和“\”两个特殊符号,导致ios编码后上传图片到服务器,服务器解码以后的值会不一致,导致图片损坏. 解决办法:重写Base64类,用“(”和“)”替换“+”和“\”两个特 ...
随机推荐
- Spring Cloud-Eureka实现服务的注册与发现(二)
在Spring Cloud中是使用Eureka来实现服务的注册与发现的 请勿使用eureka2.x 用于生产 2.x已经停止开发了 使用1.x 最新版是1.9 我这里demo是使用1.9 详 ...
- Java 集合之Collection 接口和遍历方法
这几篇是我按网上的教程来实习的. URL: http://www.cnblogs.com/jbelial/archive/2013/03/27/2981395.html 打代码的感觉挻好的.. 注意在 ...
- Spring Boot项目@RestController使用重定向redirect
Spring MVC项目中页面重定向一般使用return "redirect:/other/controller/";即可.而Spring Boot使用了@RestControll ...
- 非form表单提交的数据就要用@requestbody注解获取http传过来的值,尤其json
非form表单提交的数据就要用@requestbody注解获取http传过来的值,尤其json
- [Cypress] Stub Network Requests in a Cypress Test
To keep our tests fast and easily repeatable, it makes sense to create many integration tests and fe ...
- hdoj 3488 Tour 【最小费用最大流】【KM算法】
Tour Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submi ...
- cocos2d-x的gitignore配置
# Ignore thumbnails created by windows Thumbs.db # Ignore files build by Visual Studio *.obj *.exe * ...
- 【POJ 3744】 Scout YYF I
[题目链接] http://poj.org/problem?id=3744 [算法] 概率DP + 矩阵乘法 [代码] #include <algorithm> #include < ...
- [xPlugin] smartupload jsp图片上传
URL:http://www.cnblogs.com/ISeeYouBlogs/p/jsp.html 1.要实现图片上传,首先需要一个组件,这里我用的是smartupload.jar可以到这里下载ht ...
- Promise解决回调地狱
Promise是JavaScript异步操作解决方案.介绍Promise之前,先对异步操作做一个详细介绍. JavaScript的异步执行 概述 Javascript语言的执行环境是”单线程”(sin ...