2011-08-04 155 views
0

可能重复:
Redirect with POST data是否可以使用POST请求而不是GET请求重定向到URL?

是否有可能为一个脚本来重定向到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> 

这与MCImageManagerMCFileManager文件包的例子。

由于在HTML中使用了相对文件路径,因此无法轻松更改,因此,在此实例中回应出curl请求的响应将不起作用

+0

[重定向POST数据](http://stackoverflow.com/questions/6614076/redirect-with-post-data)和[PHP POST重定向数据](http://stackoverflow.com/问题/ 5576619/php-redirect-with-post-data) – deceze

+0

@deceze同意 - 投票结束。我没有看到那些在我的搜索。 – Treffynnon

回答

1

不,这是不可能的。

你必须使用Javascript来提交表单或做一个AJAX POST。

相关问题