masroore / CurlSharp

CurlSharp - .Net binding and object-oriented wrapper for libcurl.
BSD 3-Clause "New" or "Revised" License
182 stars 71 forks source link

CurlHttpMultiPartForm > CurlFormOption.File does not work :( #7

Closed http200it closed 8 years ago

http200it commented 9 years ago

Hello again. It does not work to send a file or send wrong? My test C# code: string avatar = Application.StartupPath + @"\avatary\myface.jpg"; var mf = new CurlHttpMultiPartForm(); mf.AddSection(CurlFormOption.CopyName, "parm1", CurlFormOption.CopyContents, "value1", CurlFormOption.End); mf.AddSection(CurlFormOption.CopyName, "parm2", CurlFormOption.CopyContents, "value2", CurlFormOption.End); if (File.Exists(avatar)) { mf.AddSection(CurlFormOption.CopyName, "uploadedfile", CurlFormOption.File, avatar, CurlFormOption.ContentType, "application/application/binary", CurlFormOption.End); Console.WriteLine(avatar); } easy.HttpPost = mf;

<?php // dotetspostfile.php print_r($_POST); print_r($_FILES);

$headers = apache_request_headers();

foreach ($headers as $header => $value) { echo "$header: $value \r\n"; } ?>

My OUT: Array ( [parm1] => value1 [parm2] => value2 ) Array ( ) Host: www.testsite.com Connection: close Content-Length: 246 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101 Firefox/22.0 Accept-Encoding: gzip,deflate Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: pl,en-us;q=0.7,en;q=0.3 Cache-Control: max-age=0 Pragma: no-cache Content-Type: multipart/form-data; boundary=------------------------e489e380b38b4322