Fw: [問題]client 端傳照片給 web 端的相關問題

看板C_Sharp作者 (李崩子)時間8年前 (2015/08/26 01:42), 編輯推噓2(207)
留言9則, 3人參與, 最新討論串1/2 (看更多)
※ [本文轉錄自 C_and_CPP 看板 #1LtAZLEy ] 作者: sqrt1089 (李崩子) 看板: C_and_CPP 標題: [問題]client 端傳照片給 web 端的相關問題 時間: Wed Aug 26 01:41:35 2015 開發平台(Platform): (Ex: VC++, GCC, Linux, ...) C# 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 應該是沒.... 問題(Question): 如題,client 端該怎麼寫 上傳照片的相關code (已GOOGLE) 餵入的資料(Input): Url跟 FilePath 預期的正確結果(Expected Output): 期許我上傳照片能到我的server裡面 錯誤結果(Wrong Output): 路徑中有不合法的字元。 行 41: byte[] btResponse = oWebClient.UploadFile("http://XX.XX.XX.XX/Play/Handler1.ashx", "POST", "@D:\temp\test.jpg"); 程式碼(Code):(請善用置底文網頁, 記得排版) 我這是包在一個btn裡面 相關程式碼如下 WebClient oWebClient = new WebClient(); byte[] btResponse = oWebClient.UploadFile("http://xx.xx.xx.xx/Play/Handler1.ashx", "POST", "@D:\temp\test.jpg"); 補充說明(Supplement): 我google 參考網址:https://msdn.microsoft.com/zh-tw/library/36s52zhs(v=VS.110).aspx MSDN說明如下 address 類型:System.String 要接收檔案之資源的 URI。 例如 ftp://localhost/samplefile.txt. fileName 類型:System.String 要傳送至資源的檔案。 例如,"samplefile.txt"。 他的範例: byte[] responseArray = myWebClient.UploadFile(uriString,fileName); //////////// 另外以下程式碼是我的ashx端的,就是從客戶端接收到照片,我做存檔的動作 foreach (string f in context.Request.Files.AllKeys) { HttpPostedFile file = context.Request.Files[f]; file.SaveAs("C:\\" + file.FileName); } 不知道我用法是否正確= = 感謝大大觀看,謝謝,感激不盡~ -- \ ∩──、 ===== \/ ● , \ ====== /\( ● ¯● |つ | ╳_入_ノ ミ ︵ 用這種餌 (_/ ノ / / 也想讓本大爺上鉤… /\___ノ_/ / ====== -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.223.173 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1440524501.A.3BC.html

08/26 01:42, , 1F
...PO錯版
08/26 01:42, 1F
※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: sqrt1089 (114.25.223.173), 08/26/2015 01:42:37

08/26 15:22, , 2F
上傳走 http 不是這樣用的 你的client是windows app
08/26 15:22, 2F

08/26 15:22, , 3F
?
08/26 15:22, 3F

08/26 15:28, , 4F
forget what i said, @的位置要放在""前面
08/26 15:28, 4F

08/26 16:03, , 5F
OK已經修正了,出現遠端伺服器傳回一個錯誤: (500) 內
08/26 16:03, 5F

08/26 16:50, , 6F
你想上傳圖片到server裡是嗎?
08/26 16:50, 6F

08/26 19:17, , 7F
08/26 19:17, 7F

08/26 19:18, , 8F
有用過64base,但是再找有沒有直接是實體直接過去
08/26 19:18, 8F

08/26 19:19, , 9F
我今天弄的進度,好像不是client端的錯了
08/26 19:19, 9F

08/26 19:20, , 10F
應該是接收端沒寫好而出錯
08/26 19:20, 10F
文章代碼(AID): #1LtAaFuB (C_Sharp)
文章代碼(AID): #1LtAaFuB (C_Sharp)