Note that there are some explanatory texts on larger screens.

plurals
  1. POposting multipart form from php online ( everything ok on localhost )
    primarykey
    data
    text
    <p>this i my code that on localhost outputs the correct text version of the pdf but when i put it on the online it doesnt send the file correctly os something like that and doesnt ouptu the convertet text . please need some help </p> <pre><code>&lt;?php //Target url $url = "http://service.coolutils.com/PDF-Converter.php"; //Boundary definition $boundary = "---------------------".substr(md5(rand(0,32000)), 0, 10); //Post data $data = ""; //Fields $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"ConvertTo\"\n\ntxt\n"; $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"Converter\"\n\npc\n"; $data .= "--$boundary\n"; //Files $fileContents = file_get_contents('test.pdf'); $data .= "Content-Disposition: form-data; name=\"filename\"; filename=\"test.pdf\"\n"; $data .= "Content-Type: application/pdf\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $fileContents."\n"; $data .= "--$boundary\n"; //Header //$optional_headers = header('Content-Type: multipart/form-data; boundary='.$boundary); //Construct params $params = array('http' =&gt; array( 'method' =&gt; 'POST', 'header' =&gt; 'Content-Type: multipart/form-data; boundary='.$boundary, 'content' =&gt; $data )); //Create context $ctx = stream_context_create($params); //Post data to url $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { echo "Error posting to $url: " . $php_errormsg; exit(1); } //Read response $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); exit(1); } //Display response (with a little bit of formatting) $response = strip_tags($response); $response = preg_replace('/\s+\n/', "\n", $response); $response = preg_replace('/\n\s+/', "\n", $response); $response = preg_replace("'[ ]+'", ' ', $response); echo $response; echo "Done"; ?&gt; </code></pre> <p>UPDATE 14/04 - i simplified the code to make it more clear . Im using WAMP (win32) on localhost and it work vary well. the problem is that it doesnt work on linux server online. </p> <p>the file "test.pdf" is located in the same folder of the script so anyone who will say that the problem is there just dont say it :D</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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