I wanted a solution to do exactly what this html does, however using only php: upload a given binary and normal fields (strings).
<center>
<form enctype="multipart/form-data" action="http://10.40.0.241/api/mailingup/index.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="9000000" />
<input type="hidden" name="uploading" value="42">
<table cellspacing=0 cellpadding=0>
<tr><td>Login</td><td><input type="text" name="login"></td></tr>
<tr><td>Senha</td><td><input type="text" name="senha"></td></tr>
<tr><td>Auto DDD</td><td><input type="checkbox" name="auto_ddd"></td></tr>
<tr><td>DDD</td><td><input type="text" name="ddd"></td></tr>
<tr><td class="option1">Campanha ID</td><td class="option1"><input type="text" name="CampanhaId"></td></tr>
<tr><td class="option2">Arquivo</td><td class="option2"><input type="file" name="arquivo" style="width:500px;"></td></tr>
</table>
<INPUT TYPE="SUBMIT" NAME="Salvar" VALUE="Carregar" onclick="SalvarOperador();">
</form>
I made a code but it did not work.
<?php
$arq = fopen("teste.csv", 'rb');
$fileContents = stream_get_contents($arq);
fclose($arq);
$campos = array(
"login" => "rafael",
"senha" => "master",
"CampanhaId" => "177",
"arquivo" => $fileContents,
"uploading" => "42",
"auto_ddd" => "on",
"ddd" => "21"
);
$content = http_build_query($campos);
$context = stream_context_create(
array(
"http" => array(
'Content-type' => 'application/x-www-form-urlencoded'
'method' => 'POST',
'content' => $content
)
)
);
$url = 'http://10.40.0.241/api/mailingup/index.php';
$fp = fopen($url, 'rb',false,$context);
echo stream_get_contents($fp);
? >