Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you can do it in the same way. Just this time your server who received the file first is the client and the second server is your server. Try using these:</p> <p>For the webpage on the second server:</p> <pre><code> &lt;form&gt; &lt;input type="text" name="var1" /&gt; &lt;input type="text" name="var2" /&gt; &lt;input type="file" name="inputname" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>And as a script to send the file on the first server:</p> <pre><code>&lt;?php function PostToHost($host, $port, $path, $postdata, $filedata) { $data = ""; $boundary = "---------------------".substr(md5(rand(0,32000)),0,10); $fp = fsockopen($host, $port); fputs($fp, "POST $path HTTP/1.0\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: multipart/form-data; boundary=".$boundary."\n"); // Ab dieser Stelle sammeln wir erstmal alle Daten in einem String // Sammeln der POST Daten foreach($postdata as $key =&gt; $val){ $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"".$key."\"\n\n".$val."\n"; } $data .= "--$boundary\n"; // Sammeln der FILE Daten $data .= "Content-Disposition: form-data; name=\"{$filedata[0]}\"; filename=\"{$filedata[1]}\"\n"; $data .= "Content-Type: image/jpeg\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $filedata[2]."\n"; $data .= "--$boundary--\n"; // Senden aller Informationen fputs($fp, "Content-length: ".strlen($data)."\n\n"); fputs($fp, $data); // Auslesen der Antwort while(!feof($fp)) { $res .= fread($fp, 1); } fclose($fp); return $res; } $postdata = array('var1'=&gt;'test', 'var2'=&gt;'test'); $data = file_get_contents('Signatur.jpg'); $filedata = array('inputname', 'filename.jpg', $data); echo PostToHost ("localhost", 80, "/test3.php", $postdata, $filedata); ?&gt; </code></pre> <p>Both scripts are take from here: <a href="http://www.coder-wiki.de/HowTos/PHP-POST-Request-Datei" rel="nofollow noreferrer">http://www.coder-wiki.de/HowTos/PHP-POST-Request-Datei</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload