2012-07-12 3 views
1

나는 Blueimp jQuery 파일 업 로더 을 구현하려고하고 있으며, 내 PHP 기반 사이트에서 작동하도록 초조 한 시간을 보내고 있습니다.Blueimp jQuery 파일 업 로더를 PHP와 함께 사용하는 방법?

내 주요 문제는 AJAX입니다. 는 내가 뭘 원하는

  1. 가 리디렉션 것 abc.php을 (의 말)하자, 업로드 후입니다.
  2. (페이지를 리디렉션하기 전에) 업로드 한 후 파일 이름을 MySQL 데이터베이스에 저장하려고합니다.

PHP로 데이터베이스를 처리하는 방법을 알고 있지만 PHP 코드를 어디에 둘 수 없는지 잘 모릅니다. 내가 만에 main.js

$(function() { 

'use strict'; 

// Initialize the jQuery File Upload widget: 
$('#fileupload').fileupload(); 

// Enable iframe cross-domain access via redirect option: 
$('#fileupload').fileupload(
    'option', 
    'redirect', 
    window.location.href.replace(
     /\/[^\/]*$/, 
     '/cors/result.html?%s' 
    ) 
);  
    // Load existing files: 
    $('#fileupload').each(function() { 
     var that = this; 
     $.getJSON(this.action, function (result) { 
      if (result && result.length) { 
       $(that).fileupload('option', 'done') 
        .call(that, null, {result: result}); 
      } 
     }); 
    }); 


}); 

감사를 변경해야 할 것 같아요 첫 번째 문제를 들어

..

답변

1

리디렉션을 수행하려면 당신이 더 나은 제외하고는 양식을 제출하고 PHP를 통해 모두 처리 할 수 ​​있습니다 당신은 내가 추측하는 진행 지표를 잃는다.

그렇지 않으면 제대로 이해했다면 업로드 완료시 자바 스크립트 리디렉션을 수행하기 위해 콜백 함수를 사용하기 만하면됩니다. How to redirect to another webpage in JavaScript/jQuery?

:

$('#fileupload').fileupload({ 
done: function (e, data) { 
    // Do redirect using either href or replace method 

    // similar behavior as clicking on a link 
    window.location.href = "/abc.php"; 

    } 

}); 

가 리디렉션에 대한이 답변을 참조하십시오 : 당신은 같은 방법 중 하나에 옵션을 추가

관련 문제