導航:首頁 > 操作系統 > androidnet上傳文件

androidnet上傳文件

發布時間:2022-06-13 20:46:31

1. android的.apk文件怎麼上傳到手機

具體方法如下:

1、首先打開電腦上的qq,在首界面找到我的設備。

同時打開手機qq,並連上無線。

2. android如何將圖片上傳到asp.net編寫的webservice

利用二進制流來傳
asp.net編寫web service時候,給個參數byte[],然後把這個byte[]存儲成圖片。用FileStream就可以。

android在調用時將需要上傳的圖片轉換為byte[]就可以了。

3. android開發怎麼實現拍照上傳

這個其實是一個很泛的問題

我大致說下我的思路:

  1. 用startactivityforresult方法調用系統的攝像頭,隨便拍張照片,把照片保存在某一目錄下面

  2. 點擊完成後,會在onactivityresult中,根據目錄的地址,再把這目錄下面的資源得轉換為文件,接著通過介面進行提交。提交成功後,後台返回一個URL。

  3. 通過這個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();
}
}
}
}
}
}

閱讀全文

與androidnet上傳文件相關的資料

熱點內容
廣數980tb3用g83鑽孔怎麼編程 瀏覽:576
程序員上海與北京 瀏覽:404
安卓手機的動態照片為什麼卡 瀏覽:538
ad編譯集成庫時最常見的問題 瀏覽:846
matlab微分方程編程 瀏覽:700
安卓手機如何打開esp文件 瀏覽:545
什麼app能安裝應用 瀏覽:199
手機用什麼app看電視劇電影好 瀏覽:603
導入原理圖為什麼文件夾不顯示 瀏覽:653
androidapp風格 瀏覽:209
php取伺服器url地址 瀏覽:293
linux時間調度演算法 瀏覽:769
單片機最小電路詳解 瀏覽:185
請求要求命令 瀏覽:806
電腦文件夾發微信顯示被佔用 瀏覽:295
手機怎麼看加密視頻 瀏覽:206
怎樣解壓手機es文件包 瀏覽:661
2017年學什麼編程 瀏覽:935
金融期貨pdf 瀏覽:694
程序員客棧的信息保密嗎 瀏覽:507