Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. i have problem with uploading image to server using httpwebrequest

i have problem with uploading image to server using httpwebrequest

Scheduled Pinned Locked Moved C#
helpcsharpphpdotnetcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TAREQ F ABUZUHRI
    wrote on last edited by
    #1

    i try to upload image to PHP server but still have problem when i access url direct http://images3.souq.com/upload\_pict\_url.php i can send image please HELP >>>> private void button1_Click(object sender, EventArgs e) { //using System.IO;//using System.Net; HttpWebResponse response; Stream resStream; StreamReader objSR; CookieContainer cookieContainer = new CookieContainer(); ASCIIEncoding encoding = new ASCIIEncoding(); HttpWebRequest request; string sResponse; string postData; string UrlLogin; try { UrlLogin = "http://images3.souq.com/upload_pict_url.php"; //UrlLogin = "http://localhost:63637/whois/test0.aspx"; string uploadfile = "C:\\fax\\pics\\7130570.jpg"; string fileFormName = "userfile"; string contenttype = "image/jpeg";//"image/pjpeg"; request = (HttpWebRequest)WebRequest.Create(UrlLogin); //request.Accept = "*/*"; request.KeepAlive = true; request.CookieContainer = cookieContainer; string boundary = "----------" + DateTime.Now.Ticks.ToString("x"); request.ContentType = "multipart/form-data; boundary=" + boundary; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; request.Method = "POST"; request.AllowAutoRedirect = true; StringBuilder sb = new StringBuilder(); string name1 = "wm_flag"; string value1 = "0"; sb.Append("--"); sb.AppendLine(boundary); sb.AppendLine(string.Format("Content-Disposition: form-data; name=\"{0}\"", name1)); sb.AppendLine(); sb.AppendLine(value1); sb.Append("--"); sb.Append(boundary); sb.Append("\r\n"); sb.Append("Content-Disposition: form-data; name=\""); sb.Append(fileFormName); sb.Append("\"; filename=\""); sb.Append(Path.GetFileName(uploadfile)); sb.Append("\""); sb.Append("\r\n"); sb.Append("Content-Type: "); sb.Append(contenttype); sb.Append("\r\n"); sb.Append("\r\n"); string postHeader =

    J 1 Reply Last reply
    0
    • T TAREQ F ABUZUHRI

      i try to upload image to PHP server but still have problem when i access url direct http://images3.souq.com/upload\_pict\_url.php i can send image please HELP >>>> private void button1_Click(object sender, EventArgs e) { //using System.IO;//using System.Net; HttpWebResponse response; Stream resStream; StreamReader objSR; CookieContainer cookieContainer = new CookieContainer(); ASCIIEncoding encoding = new ASCIIEncoding(); HttpWebRequest request; string sResponse; string postData; string UrlLogin; try { UrlLogin = "http://images3.souq.com/upload_pict_url.php"; //UrlLogin = "http://localhost:63637/whois/test0.aspx"; string uploadfile = "C:\\fax\\pics\\7130570.jpg"; string fileFormName = "userfile"; string contenttype = "image/jpeg";//"image/pjpeg"; request = (HttpWebRequest)WebRequest.Create(UrlLogin); //request.Accept = "*/*"; request.KeepAlive = true; request.CookieContainer = cookieContainer; string boundary = "----------" + DateTime.Now.Ticks.ToString("x"); request.ContentType = "multipart/form-data; boundary=" + boundary; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; request.Method = "POST"; request.AllowAutoRedirect = true; StringBuilder sb = new StringBuilder(); string name1 = "wm_flag"; string value1 = "0"; sb.Append("--"); sb.AppendLine(boundary); sb.AppendLine(string.Format("Content-Disposition: form-data; name=\"{0}\"", name1)); sb.AppendLine(); sb.AppendLine(value1); sb.Append("--"); sb.Append(boundary); sb.Append("\r\n"); sb.Append("Content-Disposition: form-data; name=\""); sb.Append(fileFormName); sb.Append("\"; filename=\""); sb.Append(Path.GetFileName(uploadfile)); sb.Append("\""); sb.Append("\r\n"); sb.Append("Content-Type: "); sb.Append(contenttype); sb.Append("\r\n"); sb.Append("\r\n"); string postHeader =

      J Offline
      J Offline
      JF2015
      wrote on last edited by
      #2

      Please don't crosspost. You already asked this question in the Q&A section: http://www.codeproject.com/Questions/125394/problem-with-uploading-image-to-server-using-httpw.aspx[^]

      T 1 Reply Last reply
      0
      • J JF2015

        Please don't crosspost. You already asked this question in the Q&A section: http://www.codeproject.com/Questions/125394/problem-with-uploading-image-to-server-using-httpw.aspx[^]

        T Offline
        T Offline
        TAREQ F ABUZUHRI
        wrote on last edited by
        #3

        it's different problem please see it ..

        Palestine

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups