Note that there are some explanatory texts on larger screens.

plurals
  1. POcURL Simple File Upload - 417 Expectation Failed
    text
    copied!<p>I have a problem with a simple file upload post with cURL... I did it so many times but in this case I always get "417 Expectation Failed" from server. When I try to post with my browser it works 100% but with cURL not. </p> <p>That's my configuration:</p> <p>My simple test form that works:</p> <pre><code>&lt;form action="http://images.example.com/image_upload.php" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="userfile" size="50"&gt; &lt;input type="submit" name="submit"&gt; &lt;/form&gt; </code></pre> <p>here the image_upload.php:</p> <pre><code>&lt;?php $uploaddir = '/var/www/images.example.com/images/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Upload failed"; } ?&gt; </code></pre> <p>my cURL script (image_upload.sh) looks like this:</p> <pre><code>#!/bin/sh file=$1 result=$(curl -s -L -F "userfile=@$file;type=application/octet-stream;" "http://images.example.com/image_upload.php") echo $result </code></pre> <p>and here the server headers: </p> <pre><code>&gt; POST /image_upload.php HTTP/1.1 &gt; User-Agent: curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.1.4 libidn/1.8 libssh2/0.18 &gt; Host: images.example.com &gt; Accept: */* &gt; Content-Length: 579 &gt; Expect: 100-continue &gt; Content-Type: multipart/form-data; boundary=----------------------------e237975526cf &gt; &lt; HTTP/1.1 417 Expectation Failed &lt; Connection: close &lt; Content-Length: 0 &lt; Date: Thu, 02 Feb 2012 21:29:22 GMT &lt; Server: lighttpd/1.4.19 </code></pre> <p>I don't know where the error is, maybe you can recognize it.</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