2011-08-04 3 views
0

가능한 중복 : 스크립트는 PHP에서 POST 요청이있는 URL로 리디렉션하는
Redirect with POST dataGET 요청 대신 POST 요청이있는 URL로 리디렉션 할 수 있습니까?

은 가능합니까?

현재 코드는 페이지 본문이로드 될 때 javascript를 사용하여 양식을 제출합니다. 가능하다면 이것을 피하고 좀 더 강력한 솔루션을 사용하고 싶습니다.

현재의 코드는 다음과 같습니다 다음 MCImageManagerMCFileManager 파일 패키지의 예입니다

<?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> 

합니다.

컬링 요청의 응답을 반향하는 것은 HTML에서 상대 파일 경로를 사용하기 때문에이 경우에을 사용할 수 없습니다.이 파일 경로는 쉽게 변경할 수 없습니다.

+0

[POST 데이터로 리디렉션] (http://stackoverflow.com/questions/6614076/redirect-with-post-data) 및 [POST 데이터가있는 PHP 리디렉션] (http://stackoverflow.com/ 질문/5576619/php-redirect-with-post-data) – deceze

+0

@deceze agree - 투표 종료. 내 검색에서 그걸 보지 못했습니다. – Treffynnon

답변

1

아니요, 불가능합니다.

양식을 제출하거나 AJAX POST를 수행하려면 자바 스크립트를 사용해야합니다.

관련 문제