gpt4 book ai didi

php - Smarty IE9 请求下载 index.php 文件(在没有上传之后)?是我的代码有问题还是 activecollab?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:50:42 26 4
gpt4 key购买 nike

好吧,当我在 php 中使用 smarty 测试文件上传时,我收到了来自 Internet Explorer 的奇怪的意外响应。

这是我用于文件上传的聪明代码(view),简化为主要问题,对于那些没有使用过 activecollab 的人来说,Router::assemble 只是形成一个带有从 MVC 读取的参数的 url。

interface
(来源:iforce.co.nz)

 <div id="xero_invoice_manager_api">
{form action=Router::assemble('xero_invoice_manager_api') method=post id="xero_invoice_manager" enctype="multipart/form-data"}
<div class="content_stack_wrapper">

<input type="file" name="file_1" /><br/>
<input type="file" name="file_2" /><br/>
{wrap_buttons}
{submit success_event="api_updated" }Authenticate{/submit}
{/wrap_buttons}
{/form}
</div></div>

这是我的 view jquery。

 App.Wireframe.Events.bind('api_event_finished.content', function(event, settings) {
App.Wireframe.Flash.success(App.lang('Xero Invoice Manager has saved/uploaded your Xero API data.'));
});

这是我的简化 Controller (我发现问题出在 smarty 而不是 php)。

//api view
function api(){
if ( $this->request->isSubmitted()) {
$this->response->respondWithData(true);
}
}

这是我正在上传的 Controller ..

//api view
function api(){
$this->assignSmarty();
if ($this->request->isSubmitted()) {
$this->XeroAuthUpdate(); //update everything
if(isset($_FILES)){
$file_manager = new XeroFileManager();
$file_manager->dumpFiles($_FILES);
//upload the files
foreach($_FILES as $file){
$file_manager->handle_certificate_file($file);
} //foreach add the headers
if(function_exists('headers_list')){
xeroDebugMode("[Controller] the headers to be sent are... ", headers_list());
} //function check
} //end if
$this->response->respondWithData(array(
// constraints
'key_result' => (bool)$this->checkValue(XeroAuths::getSetting('xero_consumer')),
'secret_result' => (bool)$this->checkValue(XeroAuths::getSetting('xero_secret')),
// files secruity certificates
'publickey' => (bool)file_exists(XERO_PUBLIC_KEY_PATH),
'privatekey' => (bool)file_exists(XERO_PRIVATE_KEY_PATH),
'xero_auth' => (bool)validateXeroAuth(),
//login constraints
'install' => !$this->checkInstallRequirements(),
));
} //close the request
}

这是来自 firefox 的响应,其中 file_1file_2 不为空。

firefox
(来源:iforce.co.nz)

这是来自 Internet Explorer 9 的响应,其中包含 file_1file_2 empty(到目前为止一切正常)。

ie empty
(来源:iforce.co.nz)

这是来自 Internet Explorer 9 的有问题的响应,其中包含 file_1(即 publickey.cer)和 file_2(即 privatekey.pem)< b>不为空(下载 index.php 吧?)。

not empty
(来源:iforce.co.nz)

我在 activecollab 的回复

Hello Micheal,

Sorry for the late reply.

Unfortunately we cannot figure out where the problem is. It looks like everything is written OK but without dealing with the code itself there's pretty much nothing we can do. Dealing with JSON responses in IE works fine across activeCollab (well, not in IE6) since almost everything in aC 3 is based on JSON, which makes your issue specific and probably there's something wrong in your code.

Regards, Oliver Maksimovic activeCollab development & support

General and Pre-Sale Questions: 1-888-422-6260 (toll-free) Technical Support: support@activecollab.com

同事建议..

Would suggest trying the following though: 1) open IE -> open the developer tools (press F12) -> Click "Cache" in menu -> click "Clear Browser Cache"... When thats finished click "Cache" and then click "Always refresh from server".

this forces IE to not cache anything, as I've had numerous times where IE was caching ajax requests and causing some very strange behaviour.

let me if this fixes your problem, and if so we can add some php to your ajax response to force all browsers to never cache the response. otherwise if that still doesn't work, probably need to do some JS debugging in IE, to see what's being sent and compare it to your FF firebug results.

headers_sent() 出现空白

但是 headers_list(就在调用 respondWithData 之前),用于 Internet Explorer。

2012-08-08 06:50:16 the headers sent from this request is... Array
(
[0] => X-Powered-By: PHP/5.3.8
[1] => Set-Cookie: ac_activeCollab_sid_yhRk0xSZku=1%2Fhkykz0Rw0796e4lDykXekNXvhMMxC8pV4akJPMvA%2F2012-08-08+06%3A50%3A15; expires=Wed, 22-Aug-2012 06:50:15 GMT; path=/
[2] => Content-Type: application/json
[3] => Expires: Mon, 26 Jul 1997 05:00:00 GMT
[4] => Cache-Control: no-cache, no-store, must-revalidate
[5] => Pragma: no-cache
)

来自 Fiddler 和 Internet Explorer 上的 Raw 选项卡的响应 header

HTTP/1.1 200 OK
Date: Sat, 11 Aug 2012 08:08:46 GMT
Server: Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: ac_activeCollab_sid_yhRk0xSZku=11%2Fz8rWxiRchAh8EWinYO2d7a1mmvn2DMKUdse1vfKh%2F2012-08-11+0 8%3A08%3A46; expires=Sat, 25-Aug-2012 08:08:46 GMT; path=/
Content-Length: 107
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8

{"key_result":true,"secret_result":true,"publickey":true,"privatekey":true,"xero_auth":true,"install":true}

来自 Firefox 上的 Raw 选项卡的响应 header 。

HTTP/1.1 200 OK
Date: Sat, 11 Aug 2012 08:13:45 GMT
Server: Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: ac_activeCollab_sid_yhRk0xSZku=12%2FO40CbXC9Vfa7OVnderlK2MFnvnpkyeckvO0Ab5NQ%2F2012-08-11+08%3A13%3A45; expires=Sat, 25-Aug-2012 08:13:45 GMT; path=/
Content-Length: 107
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8

{"key_result":true,"secret_result":true,"publickey":true,"privatekey":true,"xero_auth":true,"install":true}

关于我在使用 IE 时做错了什么有什么想法吗?以及为什么 Internet Explorer 通知用户下载 index.php(当字段具有值时)。请记住,服务器端并未发生实际上传(在初始测试期间,index.php 下载请求与 move_uploaded_file 无关)。

最佳答案

可能是 IE 特定代码有错误,因此返回的内容类型不同。如果您对某种 XML 或 JSON 数据发出 AJAX 请求,却得到某种内容类型或配置与预期不同的文件 HTML 错误响应,浏览器可能不知道如何处理它。

您可能想找到一种方法来查看或记录网络服务器发送的响应(与请求相对) header 。通常文件下载的提示来自内容配置 header ...尽管在这种情况下可能只是因为它是来自异步请求的文件。

您可能还想看看:

IE prompts to open or save json result from serverHow can I convince IE to simply display application/json rather than offer to download it?

关于php - Smarty IE9 请求下载 index.php 文件(在没有上传之后)?是我的代码有问题还是 activecollab?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11750166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com