I use a wrapper for CURL https://github.com/php-curl-class/php-curl-class , I can not send an empty form, but it is sent through the browser without problems:

------ WebKitFormBoundaryBxiCiV4ihQEhlxAg Content-Disposition: form-data; name = "FileInput"; filename = "" Content-Type: application / octet-stream

My workaround (request is accepted by the server, but it constantly generates files on it):

$FileInput = tempnam('', mt_rand()); rename($FileInput, $FileInput = substr($FileInput, 0, (strrpos($FileInput, "."))) . '.txt'); $this->curl->post('http://site.com/' . $offer_id, array( 'FileInput' => '@' . $FileInput, 'txtPercent' => $percent )); 

The server swears in response, if you make empty 'FileInput' => '' that there is no filename

  • If I understand the question correctly, then you need something like this: stackoverflow.com/questions/32511502/… - AK
  • @AK, yes, googling also saw this post, only how to do it with the used php-curl-class, and not on pure CURL? - aliokero pm
  • This library did not use before, but. You look at the library code and in the post, pass $ data not with an array , but rather shaped like the body specified above. You can also try this simplified version: stackoverflow.com/questions/13071747/… - AK
  • Hm Well, look: anyway, this library considers that the file must be - in the buildPostData lines with CURLFile and then you create a temporary file, make a request, then delete (alternatively: create once and leave as part of the project). Either generate fake data from a non-existent file, then manually collect the code from the two links that I gave. Either fork, write your own modification and offer the author a pull-ryquest;) - AK

1 answer 1

Not sure, but judging by this question should help such a dirty hack:

  $this->curl->post('http://site.com/' . $offer_id, array( //'FileInput' => '@' . $FileInput, 'attchmnt[0]"; FileInput=""'."\r\n".'Content-Type: octet-stream' => '', 'txtPercent' => $percent )); 
  • Thanks, the hack really works, only like this $ data [$ key. '"; filename =" "'." \ r \ n ". 'Content-Type: octet-stream'] = ''; - aliokero