C3rd
Visual C# Upload File/Image via PHP with Squid-Cache in the Network
Posted: 27 Jan 2012, 1:10am - FridayToday, I've been developing an oDesk-like activity monitoring application but for local network for my company, Innermax Support, and I came across with a problem of an errors:
- An exception occurred during a WebClient request.
- The remote server returned an error: (417) Expectation failed.
public void uploadFile() { try { // decleration of webclient ServicePointManager.Expect100Continue = false; System.Net.WebClient webby = new System.Net.WebClient(); //initiate credentials webby.UseDefaultCredentials = false; webby.Credentials = new NetworkCredential("anonymous", ""); //add headers webby.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.832)"); webby.Headers.Add("Content-Type", "binary/octet-stream"); //initiate upload file Byte[] result = webby.UploadFile("http://120.0.0.1/upload.php", "POST", @filename); string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); MessageBox.Show(s); webby.Dispose(); } catch (Exception) { // do nothing... MessageBox.Show("Upload failed!"); } }So far, it works fine with me and satisfied of my solution. Hope this will help your problem too... :)
Search
Categories
Related Links
- Apache Web Server
- ASP Immigration Services Ltd.
- CentOS Linux
- Color Scheme Picker
- CSS Button Generator
- Deviant Art Account
- Don Tabaniag - GraphiCult
- Jerson Maglasang Weblog
- Joshua Manlunas
- Mark "mungkey" Vicente
- Matt Arnilo Baluyos
- MySQL
- Paul Labis
- PHP
- PrendStar
- Ridvan Baluyos
- Scott Davies
- SEO Fart XML-RPC Ping Tool
- Stripes Generator
- The Hero
- Ubuntu Linux
- Vim Carlo Nabora (DA)
- Wella Maria Hong
- What is my IP?
- Xavier University - Ateneo de Cagayan
- Zabyer Community