0
是否有可能爲一個腳本來重定向到PHP中POST請求的URL?
我當前使用的JavaScript代碼在頁面正文加載時提交表單。我想避免這種情況,如果可能的話,使用更強大的解決方案。
當前的代碼看起來是這樣的:
<?php
// Change this secret key so it matches the one in the imagemanager/filemanager config
$secretKey = "someSecretKey";
// Check here if the user is logged in or not
if (!isset($_SESSION["some_session"]))
die("You are not logged in.");
// Override any config values here
$config = array();
//$config['filesystem.path'] = 'c:/Inetpub/wwwroot/somepath';
//$config['filesystem.rootpath'] = 'c:/Inetpub/wwwroot/somepath';
// Generates a unique key of the config values with the secret key
$key = md5(implode('', array_values($config)) . $secretKey);
?>
<html>
<body onload="document.forms[0].submit();">
<form method="post" action="<?php echo htmlentities($_GET['return_url']); ?>">
<input type="hidden" name="key" value="<?php echo htmlentities($key); ?>" />
<?php
foreach($config as $key => $value) {
echo '<input type="hidden" name="' .
htmlentities(str_replace('.', '__', $key)) . '"
value="' . htmlentities($value) . '" />';
}
?>
</form>
</body>
</html>
這與MCImageManager和MCFileManager文件包的例子。
由於在HTML中使用了相對文件路徑,因此無法輕鬆更改,因此,在此實例中迴應出curl請求的響應將不起作用。
[重定向POST數據](http://stackoverflow.com/questions/6614076/redirect-with-post-data)和[PHP POST重定向數據](http://stackoverflow.com/問題/ 5576619/php-redirect-with-post-data) – deceze
@deceze同意 - 投票結束。我沒有看到那些在我的搜索。 – Treffynnon