1. android的.apk文件怎么上传到手机
具体方法如下:
1、首先打开电脑上的qq,在首界面找到我的设备。
同时打开手机qq,并连上无线。
2. android如何将图片上传到asp.net编写的webservice
利用二进制流来传
asp.net编写web service时候,给个参数byte[],然后把这个byte[]存储成图片。用FileStream就可以。
android在调用时将需要上传的图片转换为byte[]就可以了。
3. android开发怎么实现拍照上传
这个其实是一个很泛的问题
我大致说下我的思路:
用startactivityforresult方法调用系统的摄像头,随便拍张照片,把照片保存在某一目录下面
点击完成后,会在onactivityresult中,根据目录的地址,再把这目录下面的资源得转换为文件,接着通过接口进行提交。提交成功后,后台返回一个URL。
通过这个URL,运用imageload(第三方插件)显示图片
4. android开发,我想把手机上的数据上传到网页上
如果是数据同步,主要还是网络编程
客户端把数据打包发送到服务器,然后服务器解析数据,存储到数据库
然后就是你说的在网页上显示,这个说白了就是把查询数据,显示到前台
通信协议这一块可以使用TCP或者HTTP,使用HTTP的话还是方便一点如果使用TCP协议,难度可能会大一点,不过有开源的框架(Apache Mina)可以使用
5. 求助,Android如何定时上传数据到服务器
利用ftp定时上传log到其他服务器的方法
利用ftp定时上传log到其他服务器#!/bin/bash #时间的生成 Y=` date --date="-1 hour" +%Y` m=` date --date="-1 hour" +%m` d=`date --date="-1 hour" +%d` H=`date --date="-1 hour" +%H`
IPhone上传图片到服务器
求助:IPhone上传图片到服务器 我在网上看到 IPhone上传到服务器用的是php的web接收,地址: 我只会asp.net ,请问用ASP.net和IPhone怎么结合实现手机端的图片上传到服务器上? 求助!!! 重点在:if (move_uploaded_file($_FILES['u
android开发以上传图片到七牛云存储服务器
android开发之上传图片到七牛云存储服务器 相信很多开发者会把图片存放到七牛上,我的web站点也是吧图片存储到七牛上,对于以图片为主的站点,这样可以节省很大带宽。 将图片上传到七牛服务器的重点就是获得上传凭证uploadToken,直接把AccessKey和Secret放到客户端太不安全,容易被反编译。所以需要在服务器端根据AccessKey和Secret动态生成一个uploadToken,
6. android怎么在服务器和客户端之间传输图片
本地获取服务端的话,是服务端返回一个url,然后本地加载网络图片bitmap流,然后加载到imageview里,服务端的话,就是本地图片上传了
7. android 怎样上传文件至SharePoint
$File = "d:\xxx\backup\url.txt"
$backPath = "d:\xx\backup\"
$errorPath = $backPath+"error.txt"
$importListPath = $backPath+"importList.txt"
$enableBackuo = $true
$enableDelete = $false Write-Host "文件备份:" -NoNewline
if($enableBackuo) {Write-Host "允许" -ForegroundColor green }
else {Write-Host "不允许" -ForegroundColor red}
Write-Host "文件删除:" -NoNewline
if($enableDelete) {Write-Host "允许" -ForegroundColor green}
else {Write-Host "不允许" -ForegroundColor red}
Write-Host
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-ForegroundColor green
#下载页面的全部信息包含完整的html结构
function WebClientDownload($link, $dir){
$Username = "domain\user"
$Password = "password"
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.Networkcredential($Username,
$Password)
$WebClient.DownloadFile( $link, $dir )
}
#下载页面的SharePoint信息,和ribbon菜单中的‘另存为副本’效果一样
function DownLoadPages($file,$dir){
#Downloading file
$binary = $file.OpenBinary()
$stream = New-Object System.IO.FileStream($dir), Create
$writer = New-Object System.IO.BinaryWriter($stream)
$writer.write($binary)
$writer.Close()
}
#正则过滤aspx页面
function GetMatches($link){
$reg = "(?http://[^/]+/.*)Pages(?
.*\/)(?.*)\.aspx?(?.*$)"
if($link -match $reg){
return $Matches
}
return $null
}
Get-Content $File | foreach-Object {
$regResult = GetMatches($_)
$webUrl = $regResult.web
if($regResult -eq $null){
Write-Host "$($_) --> 失败,文件格式不对" -ForegroundColor red
Out-File -FilePath $errorPath -InputObject "$($_) --无法处理" -Append
}
else{
$web = Get-SPWeb $webUrl
$list = $web.lists["页面"]
#设置导出文件的路径
$itemUrl = $regResult.page+".aspx"
$folderUrl = $regResult.dir
$fileUrl = ("pages",$folderUrl,$itemUrl -Join "")
$directory = ($backPath,$web.Title.ToString(),$folderUrl -Join "")
$outFileUrl = ($directory,$itemUrl -Join "\")
$spFolder= $web.GetFolder($list.RootFolder.Url + $folderUrl)
#$Items = $list.Items | where {$_['FileLeafRef'] -eq $itemUrl}
try{
$Items = $spFolder.Files.Item($itemUrl)
if($Items){
#判断目录是否存在
if(!(Test-Path $directory)){
New-Item -ItemType Directory -Path $directory
#new-item -path $backPath -name $web.Title.ToString() -type directory
}
DownLoadPages $web.GetFile($fileUrl) $outFileUrl
Out-File -FilePath $importListPath -InputObject
"$($_,$outFileUrl,$folderUrl,$Items.Title -Join ',')" -Append
WebClientDownload $regResult[0]
$outFileUrl.Replace(".aspx","_WebClientDownload.aspx")
if($enableDelete){
$Items.Recycle()
}
Write-Host "$($_) --> 成功" -ForegroundColor green
}
else{
Write-Host "$($_) --> 失败,文件不存在" -ForegroundColor red
#如果URL不存在或已删除,则输出提示
Out-File -FilePath $errorPath -InputObject "$($_,'not exist' -Join '--')"
-Append
}
}
catch{
Write-Host "$($regResult[0]) --> ERROR" -ForegroundColor red
Out-File -FilePath $errorPath -InputObject "$($_.exception) -- $fileUrl"
-Append
}
finally{
$web.dispose()
}
}
}
#去除重复行
$output_importlist = get-content $importListPath | sort | get-unique
Out-File -FilePath $importListPath -InputObject $output_importlist
if((Test-Path $errorPath)){
$output_error = get-content $errorPath | sort | get-unique
Out-File -FilePath $errorPath -InputObject $output_error
}
备份还原部分
?1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86#创建文件夹
function CreateFolder($spList, $folderURL)
{
[Microsoft.SharePoint.SPFolder] $spFolder =
$web.GetFolder(($list.RootFolder.Url,$folderURL -Join "/"))
if(!$spFolder.Exists)
{
if (!$list.EnableFolderCreation)
{
$list.EnableFolderCreation = true;
$list.Update();
}
$folders = $folderURL.Trim('/').Split('/');
$folderPath =""
foreach ($f in $folders)
{
$folderPath += "/" + $f;
$folder = $list.ParentWeb.GetFolder($list.RootFolder.Url +
$folderPath);
if (!$folder.Exists)
{
[Microsoft.SharePoint.SPListItem] $newFolder = $list.Items.Add("",
[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,
$folderPath.Trim('/'));
$newFolder.Update()
$newFolder["_ModerationStatus"] = 0
$newFolder.Update()
}
}
}
}
#上传文件
function UploadFile($Web, $DocLibName, $FilePath, $folderUrl)
{
$Web.AllowUnsafeUpdates = $true;
$List = $web.Lists[$DocLibName]
$RootFolder = $List.RootFolder
$FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)
$File= Get-ChildItem $FilePath
$pageUrl = ( $RootFolder.Url + $folderUrl.TrimEnd("/") +"/"+
$File.Name)
try
{
if(!$Web.GetFile($pageUrl).Exists)
{
[Microsoft.SharePoint.SPFolder] $spFolder = $web.GetFolder( $RootFolder.Url
+ $folderUrl)
$fileStream = ([System.IO.FileInfo] (Get-Item
$File.FullName)).OpenRead()
write-host "上传文件 " $File.Name " 到 " $RootFolder.Url + $folderUrl "..."
[Microsoft.SharePoint.SPFile]$spFile = $folder.Files.Add($pageUrl,
[System.IO.Stream]$fileStream, $true)
write-host "上传成功" -ForegroundColor green
write-host
$fileStream.Close()
$spFile.Item.Update()
$spFile.CheckIn("")
$spFile.Approve("")
}
}
catch
{
write-host $_.exception -ForegroundColor red
}
finally
{
$Web.AllowUnsafeUpdates = $false;
}
}
$File = "d:\zhangyuepeng\backup\importlist.txt"
Get-Content $File | foreach-Object {
$items = $_.Split(',')
$Url = $items[0]
$regResult = GetMatches($Url)
$webUrl = $regResult.web
$web = Get-SPWeb $webUrl
$list = $web.Lists["页面"]
if($items[2] -ne "/")
{
CreateFolder $list $items[2]
UploadFile $web "页面" $items[1] $items[2] $items[2]
}
else
{
UploadFile $web "页面" $items[1] "" $items[2]
}
$web.dispose()
}
8. android的自带的httpClient 怎么上传文件
Android上传文件到服务端可以使用HttpConnection 上传文件,也可以使用Android封装好的HttpClient类。当仅仅上传文件可以直接使用httpconnection 上传比较方便快捷。
1、使用HttpConection上传文件。将文件转换成表单数据流。主要的思路就自己构造个http协议内容,服务端解析报文获得表单数据。代码片段:
[java] view plain
HttpURLConnection con;
try {
con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(C_TimeOut);
/* 允许Input、Output,不使用Cache */
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
/* 设置传送的method=POST */
con.setRequestMethod("POST");
/* setRequestProperty */
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Charset", "UTF-8");
con.setRequestProperty("Content-Type","multipart/form-data;boundary=" + boundary);
/* 设置DataOutputStream */
DataOutputStream ds = new DataOutputStream(con.getOutputStream());
FileInputStream fStream = new FileInputStream(file);
/* 设置每次写入1024bytes */
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int length = -1;
/* 从文件读取数据至缓冲区 */
while((length = fStream.read(buffer)) != -1)
{
/* 将资料写入DataOutputStream中 */
ds.write(buffer, 0, length);
}
fStream.close();
ds.flush();
ds.close();
可以参考
①《在 Android 上通过模拟 HTTP multipart/form-data 请求协议信息实现图片上传》 (http://bertlee.iteye.com/blog/1134576)。
②《关于android Http访问,上传,用了三个方法 》
2、使用Android HttpClient类上传参数。下面我在网上搜到得代码,忘记出处了
[java] view plain
private static boolean sendPOSTRequestHttpClient(String path,
Map<String, String> params) throws Exception {
// 封装请求参数
List<NameValuePair> pair = new ArrayList<NameValuePair>();
if (params != null && !params.isEmpty()) {
for (Map.Entry<String, String> entry : params.entrySet()) {
pair.add(new BasicNameValuePair(entry.getKey(), entry
.getValue()));
}
}
// 把请求参数变成请求体部分
UrlEncodedFormEntity uee = new UrlEncodedFormEntity(pair, "utf-8");
// 使用HttpPost对象设置发送的URL路径
HttpPost post = new HttpPost(path);
// 发送请求体
post.setEntity(uee);
// 创建一个浏览器对象,以把POST对象向服务器发送,并返回响应消息
DefaultHttpClient dhc = new DefaultHttpClient();
HttpResponse response = dhc.execute(post);
if (response.getStatusLine().getStatusCode() == 200) {
Log.i("http", "httpclient");
return true;
}
return false;
}
3、使用httpClient上传文字信息和文件信息。使用httpClient上传文件非常的方便。不过需要导入apache-mime4j-0.6.jar 和httpmime-4.0.jar两个.jar包。
[java] view plain
// 封装请求参数
MultipartEntity mpEntity = new MultipartEntity();
if (params != null && !params.isEmpty()) {
for (Map.Entry<String, String> entry : params.entrySet()) {
StringBody par = new StringBody(entry.getValue());
mpEntity.addPart(entry.getKey(), par);
}
}
// 图片
if (!imagepath.equals("")) {
FileBody file = new FileBody(new File(imagepath));
mpEntity.addPart("photo", file);
}
// 使用HttpPost对象设置发送的URL路径
HttpPost post = new HttpPost(path);
// 发送请求体
post.setEntity(mpEntity);
// 创建一个浏览器对象,以把POST对象向服务器发送,并返回响应消息
DefaultHttpClient dhc = new DefaultHttpClient();
HttpResponse response = dhc.execute(post);
FileBody类可以把文件封装到表单中,实现附件的上传。
关于httpClient上传文件可以参考链接: http://www.eoeandroid.com/forum.php?mod=viewthread&tid=76721&page=1
需要用的的ja下载地址r:http://download.csdn.net/detail/china1988s/3791514
参考:
①《在 Android 上通过模拟 HTTP multipart/form-data 请求协议信息实现图片上传》 (http://bertlee.iteye.com/blog/1134576)。
②《关于android Http访问,上传,用了三个方法 》
9. android中如何上传图片到FTP服务器
在安卓环境下可以使用,在java环境下也可以使用,已经在Java环境下实现了功能,然后移植到了安卓手机上,其它都是一样的。
[java] view plain
package com.photo;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
public class FileTool {
/**
* Description: 向FTP服务器上传文件
*
* @param url
* FTP服务器hostname
* @param port
* FTP服务器端口
* @param username
* FTP登录账号
* @param password
* FTP登录密码
* @param path
* FTP服务器保存目录,是linux下的目录形式,如/photo/
* @param filename
* 上传到FTP服务器上的文件名,是自己定义的名字,
* @param input
* 输入流
* @return 成功返回true,否则返回false
*/
public static boolean uploadFile(String url, int port, String username,
String password, String path, String filename, InputStream input) {
boolean success = false;
FTPClient ftp = new FTPClient();
try {
int reply;
ftp.connect(url, port);// 连接FTP服务器
// 如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器
ftp.login(username, password);//登录
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
return success;
}
ftp.changeWorkingDirectory(path);
ftp.storeFile(filename, input);
input.close();
ftp.logout();
success = true;
} catch (IOException e) {
e.printStackTrace();
} finally {
if (ftp.isConnected()) {
try {
ftp.disconnect();
} catch (IOException ioe) {
}
}
}
return success;
}
// 测试
public static void main(String[] args) {
FileInputStream in = null ;
File dir = new File("G://pathnew");
File files[] = dir.listFiles();
if(dir.isDirectory()) {
for(int i=0;i<files.length;i++) {
try {
in = new FileInputStream(files[i]);
boolean flag = uploadFile("17.8.119.77", 21, "android", "android",
"/photo/", "412424123412341234_20130715120334_" + i + ".jpg", in);
System.out.println(flag);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
}
}
以上为java代码,下面是android代码。
[java] view plain
package com.ftp;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new uploadThread().start();
}
class uploadThread extends Thread {
@Override
public void run() {
FileInputStream in = null ;
File dir = new File("/mnt/sdcard/DCIM/Camera/test/");
File files[] = dir.listFiles();
if(dir.isDirectory()) {
for(int i=0;i<files.length;i++) {
try {
in = new FileInputStream(files[i]);
boolean flag = FileTool.uploadFile("17.8.119.77", 21, "android", "android",
"/", "412424123412341234_20130715120334_" + i + ".jpg", in);
System.out.println(flag);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
}
}
}