资源解释为图像,但转移与MIME类型text / html,curl,php [英] Resource interpreted as Image but transferred with MIME type text/html, curl, php
问题描述
我收到这个错误,我以前没有见过。我使用cURL尝试从我的网站获取验证码图片,但我得到这个错误,而不是我想要的图像。
if(isset($ _ GET ['captcha'])){
$ curl-> open(GET,https://mydomain.com);
$ curl-> exec();
preg_match('/ _ mobile_sess = [^;] + /',$ curl-> getHeaders(),$ sess);
$ _SESSION ['cookie'] = $ sess [0];
preg_match('/ ame =authenticity_tokentype = \hidden \value = \(。+?)\/ i',$ curl-> responseText, $ tkn);
$ _SESSION ['token'] = $ tkn [1];
preg_match('/ \ / signup \ / captcha \ /([0-9-a-z] +)\.gif / i',$ curl-> responseText,$ cs);
$ _SESSION ['captchaUrl'] = $ cs [1];
$ curl-> open(GET,http://mydomain.com。$ cs [0]);
$ curl-> cookie = $ _SESSION ['cookie'];
$ curl-> exec();
echo $ curl-> responseText;
die;
}
MIME类型为< meta http-equiv =Content-Typecontent =image / gif>
。
这是我要输出图片的表单。
if(empty($ _ SERVER ['QUERY_STRING'])){
echo< center>< form method ='POST'action ='?go'>
< input type ='hidden'name ='nameC'value =' - SAFAL - '>< br />
< b>用户名< / b>< br>< input name = login'size = '30'id ='login'value ='safal'.rand(111111,9999999)。'>< br />
< b> Password< / b> br>< input name ='senha'id ='senha'size = '30'value ='。rand()。">< br />
< img src ='?captcha'>< br />
< input name ='cs'id ='cs'placeholder ='Put Capcha'size = '20'onclick ='if value == \Digite aqui\)this.value = \\'>< br>< br>< br>
< input type ='submit' ='点击这里'id ='btn'>
< / form>;
}
如果您设置了 background-image:url '../ img / sample.png');
这样带有单引号,Chrome / Opera控制台也会显示此警告。
删除引号就是诡计。
I'm getting this error which i haven't seen before. I'm using cURL to try and get a captcha image from my site, but im getting this error instead of the image i want.
if(isset($_GET['captcha'])) {
$curl->open("GET","https://mydomain.com");
$curl->exec();
preg_match('/_mobile_sess=[^;]+/', $curl->getHeaders(), $sess);
$_SESSION['cookie'] = $sess[0];
preg_match('/ame="authenticity_token" type=\"hidden\" value=\"(.+?)\"/i',$curl->responseText, $tkn);
$_SESSION['token'] = $tkn[1];
preg_match('/\/signup\/captcha\/([0-9-a-z]+)\.gif/i', $curl->responseText, $cs);
$_SESSION['captchaUrl'] = $cs[1];
$curl->open("GET", "http://mydomain.com" . $cs[0]);
$curl->cookie = $_SESSION['cookie'];
$curl->exec();
echo $curl->responseText;
die;
}
I've set the MIME type as <meta http-equiv="Content-Type" content="image/gif">
in my head of my HTML doc but still get the same issue.
This is the form where i'm trying to output the image.
if(empty($_SERVER['QUERY_STRING'])){
echo "<center><form method='POST' action='?go'>
<input type='hidden' name='nameC' value='- SAFAL -' ><br/>
<b>User Name</b><br><input name='login' size='30' id='login' value='safal".rand(111111,9999999)."'><br/>
<b>Password</b><br><input name='senha' id='senha' size='30' value='".rand()."'><br/> <br>
<img src='?captcha'><br/>
<input name='cs' id='cs' placeholder='Put The Capcha' size='20' onclick='if(this.value==\"Digite aqui\") this.value=\"\"'><br><br><br>
<input type='submit' value='Click Here' id='btn'>
</form>";
}
Stumbled upon this question via Google Search. Adding my case for reference:
If you set a background-image: url('../img/sample.png');
like this with single quotation marks, the Chrome/ Opera console will also show this warning.
Eliminating the quotation marks does the trick.
这篇关于资源解释为图像,但转移与MIME类型text / html,curl,php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!