问题描述
我有一个简单的文件上传后与卷曲的问题...
我做了这么多次,但在这种情况下,我让永诺417预期失败的服务器。
当我尝试后与我的浏览器它的工作原理100%,但有没有卷曲。
i have a problem with a simple file upload post with cURL...i did it so many times but in this case i allways get "417 Expectation Failed" from server.When i try to post with my browser it works 100% but with cURL not.
这就是我的配置:
我简单的测试形式,多数民众赞成如下:
my simple test form thats works:
<form action="http://images.example.com/image_upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="userfile" size="50">
<input type="submit" name="submit">
</form>
在这里image_upload.php:
here the image_upload.php:
<?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";
}
?>
我卷曲的脚本(image_upload.sh)看起来是这样的:
my cURL script (image_upload.sh) looks like this:
#!/bin/sh
file=$1
result=$(curl -s -L -F "userfile=@$file;type=application/octet-stream;" "http://images.example.com/image_upload.php")
echo $result
和这里的服务器头:
> POST /image_upload.php HTTP/1.1
> 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
> Host: images.example.com
> Accept: */*
> Content-Length: 579
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------e237975526cf
>
< HTTP/1.1 417 Expectation Failed
< Connection: close
< Content-Length: 0
< Date: Thu, 02 Feb 2012 21:29:22 GMT
< Server: lighttpd/1.4.19
我不知道哪里出错,也许你可以识别它。
谢谢
i don't know where the error is, maybe you can recognize it.Thanks
推荐答案
也可以使用设置选择头设置固定的:
Can also be fixed using set opt header setting:
curl_setopt($curl,CURLOPT_HTTPHEADER,array("Expect: "));
http://www.khattam.info/417-expectation-failed-in-php-curl-while-submitting-multi-part-forms-2011-04-14.html
这篇关于卷曲简单的文件上传 - 417预期失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!