我使用html上傳功能。使用給定的代碼它工作正常。在flex中使用URLRequest無法使用文件上傳
<form id="avatar" enctype="multipart/form-data"
action="http://localhost:8080/alfresco/service/slingshot/profile/uploadavatar?
alf_ticket=TICKET_7475e180e8d258c0341fc745a3a35274d0a06e50"
method="post">
<input type="text" name="username" value="ken"/>
選擇一個文件:
<input type="file" name="filedata" />
<input type="submit" name="button" value="upload"//form
相同的功能我在柔性曾嘗試:
var uploadURL:URLRequest = new URLRequest();
uploadURL.url="http://localhost:8080/alfresco/service/slingshot/profile/uploadavatar?alf_ticket=TICKET_7475e180e8d258c0341fc745a3a35274d0a06e50"";
uploadURL.method=URLRequestMethod.POST;
uploadURL.contentType="multipart/form-data";
var params:URLVariables = new URLVariables();
params.username ="admin";
params.filedata=fileRef.data;
uploadURL.data = params;
fileRef.upload(uploadURL)
,但得到錯誤的請求錯誤。所以任何人都知道,我在代碼中犯了什麼錯誤。請與我分享。
您是否檢查了您要發送給服務器的內容?嘗試安裝www.charlesproxy.com並檢查您的請求和響應對象中的內容。希望這可以幫助。 – Simsons 2012-02-13 11:37:37