當前位置:首頁 » 文件傳輸 » http上傳文件
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

http上傳文件

發布時間: 2022-01-12 08:06:12

『壹』 用http協議如何上傳文件在什麼地方上傳

除非伺服器安裝了http上傳的插件,否則使用http上傳文件是不可能實現的

『貳』 怎麼HTTP上傳

如何用http上傳一個文件

VC裡面怎麼用http上傳一個文件呢?下載文件有這樣一個函數
HRESULT URLDownloadToCacheFile(
LPUNKNOWN lpUnkcaller,
LPCSTR szURL,
LPTSTR szFileName,
DWORD dwBufLength,
DWORD dwReserved,
IBindStatusCallback *pBSC
);
可以提供回調,顯示進度,有沒有與這個函數相對應的上傳文件的函數呢?或者還有其他的用起來比較方便的函數呢?不想用socket實現http,那樣太麻煩了,我的工程很小的,如果用socket實現http的話會得不償失的

『叄』 用http協議能不能上傳文件

能,但是要通過相應的非HTML腳本服務(比如ASP,PHP,CGI等等)

ASP,PHP,CGI是伺服器端的代碼解釋器

不但要伺服器端有這個解釋器,而且站點的頁面里也要有相應功能的代碼
要更詳細的話你恐怕真的要去學習一下ASP,PHP,CGI,JSP,XML等等比HTML更高級的腳本語言

『肆』 怎麼用http上傳一個文件到伺服器 python

首先,標准HTTP協議對上傳文件等表單的定義在這里:wwwietforg/rfc/rfc1867txt 大概數據包格式如下:

單文件:

Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="field1"

Joe Blow
--AaB03x
content-disposition: form-data; name="pics"; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x--
多文件:

Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="field1"

Joe Blow
--AaB03x
content-disposition: form-data; name="pics"
Content-type: multipart/mixed, boundary=BbC04y

--BbC04y
Content-disposition: attachment; filename="file1.txt"
其次,python上傳文件的幾種方法:

1 自己封裝HTTP的POST數據包:http//stackoverflowcom/questions/680305/using-multipartposthandler-to-post-form-data-with-python

import httplibimport mimetypesdef post_multipart(host, selector, fields, files): content_type, body = encode_multipart_formdata(fields, files) h = httplib.HTTP(host) h.putrequest('POST', selector) h.putheader('content-type', content_type) h.putheader('content-length', str(len(body))) h.endheaders() h.send(body) errcode, errmsg, headers = h.getreply() return h.file.read() def encode_multipart_formdata(fields, files): LIMIT = '----------lImIt_of_THE_fIle_eW_$' CRLF = '\r\n' L = [] for (key, value) in fields: L.append('--' + LIMIT) L.append('Content-Disposition: form-data; name="%s"' % key) L.append('') L.append(value) for (key, filename, value) in files:

『伍』 用http協議如何上傳文件

不可以,文件上傳協議是FTP協議

http是超文本協議。

『陸』 http協議上傳文件

<input type="file" />
是不是 應該添加 name="" 伺服器才能獲取到啊?要不 是不是瀏覽器 直接忽略無名稱的變數了?

PS:順便問一下,你的伺服器 用的什麼http庫??? 還是 直接 tcp socket 編程 ?

『柒』 http中上傳文件的原理

http中上傳文件的原理如下:
在最初的http協議中,沒有上傳文件方面的功能。 rfc1867 ( http://www.ietf.org/rfc/rfc1867.txt ) 為 http 協議添加了這個功能。客戶端的瀏覽器,如 Microsoft IE, Mozila, Opera 等,按照此規范將用戶指定的文件發送到伺服器。伺服器端的網頁程序,如 php, asp, jsp 等,可以按照此規范,解析出用戶發送來的文件。Microsoft IE, Mozila, Opera 已經支持此協議,在網頁中使用一個特殊的 form 就可以發送文件。絕大部分 http server ,包括 tomcat ,已經支持此協議,可接受發送來的文件。各種網頁程序,如 php, asp, jsp 中,對於上傳文件已經做了很好的封裝。

超文本傳輸協議(HTTP,HyperText Transfer Protocol)是互聯網上應用最為廣泛的一種網路協議。所有的WWW文件都必須遵守這個標准。設計HTTP最初的目的是為了提供一種發布和接收HTML頁面的方法。1960年美國人Ted Nelson構思了一種通過計算機處理文本信息的方法,並稱之為超文本(hypertext),這成為了HTTP超文本傳輸協議標准架構的發展根基。

『捌』 apache 如何http上傳文件

JAVA代碼

sql">StringtargetUrl="http://localhost:8080/Test";
PostMethodfilePost=newPostMethod(targetUrl){//這個用來中文亂碼
publicStringgetRequestCharSet(){
return"UTF-8";//
}
};
try{
HttpClientclient=newHttpClient();
Filefile=newFile("c:/新聞.xml");
Part[]parts=newPart[]{newCustomFilePart(file.getName(),file)};
filePost.setRequestEntity(newMultipartRequestEntity(parts,filePost.getParams()));
intstatuscode=client.executeMethod(filePost);
if(statuscode==HttpStatus.SC_OK){
System.out.println("添加文件成功");
}else{
System.out.println("添加文件失敗");
}
}catch(Exceptionex){
ex.printStackTrace();
}
importjava.io.File;
importjava.io.FileNotFoundException;
importjava.io.IOException;
importjava.io.OutputStream;

importorg.apache.commons.httpclient.methods.multipart.FilePart;
importorg.apache.commons.httpclient.util.EncodingUtil;
/**
*解決中文文件名亂碼
*/
{
publicCustomFilePart(Stringfilename,Filefile)
throwsFileNotFoundException{
super(filename,file);
}

(OutputStreamout)throwsIOException{
super.sendDispositionHeader(out);
Stringfilename=getSource().getFileName();
if(filename!=null){
out.write(EncodingUtil.getAsciiBytes(FILE_NAME));
out.write(QUOTE_BYTES);
out.write(EncodingUtil.getBytes(filename,"utf-8"));
out.write(QUOTE_BYTES);
}
}
}

而服務端使用apache的commonfileupload:

Filetempfile=newFile(System.getProperty("java.io.tmpdir"));//採用系統臨時文件目錄
=newDiskFileItemFactory();
diskFileItemFactory.setSizeThreshold(4096);//設置緩沖區大小,這里是4kb
diskFileItemFactory.setRepository(tempfile);//設置緩沖區目錄
ServletFileUploadfu=newServletFileUpload(diskFileItemFactory);
fu.setSizeMax(4194304);//限制文件大小最大為4M
ListfileItems=fu.parseRequest(request);
Iteratori=fileItems.iterator();
while(i.hasNext()){
FileItemfi=(FileItem)i.next();
StringfileName=fi.getName();
if(fileName!=null){
FilefullFile=newFile(fi.getName());
FilesavedFile=newFile(uploadPath,fullFile.getName());
fi.write(savedFile);
}
}
System.out.println("uploadsucceed");

『玖』 用http協議能不能上傳文件

http協議也可以上傳文件,需要利用網路語言來編寫程序進行操作。典型的例子是ASP程序中的無組件上傳方法。

『拾』 http 文件上傳

高手,給我一份代碼啊
[email protected]