上传图片到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类,用“(”和“)”替换“+”和“\”两个特 ...
随机推荐
- 继续聊WPF——Expander控件(2)
<Window x:Class="Expander_Sample2.Window1" xmlns="http://schemas.microsoft.com/win ...
- 1.git的安装和配置
从git官网下一个git安装包. 点击git.exe安装程序,点击[next] 点击[next] 根据自己的需要可以把需要安装软件全选上,点击[next] 由于这是个人使用所以选择第二 ...
- HDU 4502
直接贪心就好. #include <iostream> #include <cstdio> #include <algorithm> #include <cs ...
- rsync与cwRsync
以下这个链接是windows之间的csRsync和csRsyncServer同步教程: http://www.cnblogs.com/wwufengg/p/rsync-config.html !Att ...
- 问题1-The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
问题一:The type java.lang.String cannot be resolved. It is indirectly referenced from required .class f ...
- HDU 5063 Operation the Sequence(暴力)
HDU 5063 Operation the Sequence 题目链接 把操作存下来.因为仅仅有50个操作,所以每次把操作逆回去执行一遍,就能求出在原来的数列中的位置.输出就可以 代码: #incl ...
- PL SQL Developer client 连接server
安装完Oracle,PLSQL之后,在server中打开监听. 计算机右键-管理-服务和应用程序-服务-打开以Oracle开头的服务,特别是监听,这个最重要.详细如图所看到的. (1)配置监听的位置 ...
- python实现高速排序算法(两种不同实现方式)
# -*- coding: utf-8 -*- """ Created on Fri May 16 17:24:05 2014 @author: lifeix " ...
- 消除ADB错误“more than one device and emulator”的方法
当我连着手机充电的时候,启动模拟器调试,运行ADB指令时,报错. C:\Users\gaojs>adb shell error: more than one device and emulato ...
- luogu3690 【模板】 Link Cut Tree(动态树)
题目大意 给定n个点以及每个点的权值,要你处理接下来的m个操作.操作有4种.操作从0到3编号.点从1到n编号.0.询问从x到y的路径上的点的权值的xor和.保证x到y是联通的.1.代表连接x到y,若x ...