2012-08-29 2 views
2

나는 여기에서 길을 잃었다. SWFUpload에서 처리하는 간단한 파일 업로드를 설정하려고합니다. 파일 선택 후 아무 일도 일어나지 않습니다. 요청이 전송되는 것을 볼 수 없으며 내 콘솔에는 아무 것도 없습니다. swf 객체가 내 upload_url 페이지를 즉시 호출해야합니까? 파일을 업로드하기 시작파일 선택 후 SWFUpload를 수행 하시겠습니까?

 var swfu,jobForm; 
     var j = jQuery.noConflict(); 
     j(window).load(function() { 
      jobForm = j('.admin-atomic-form form'); 
      swfu = new SWFUpload({ 
       upload_url : "URL/upload.php", 
       flash_url : "URL/swfupload.swf", 
       file_size_limit : "20 MB", 
       file_types : "*.doc;*.pdf;*.rtf;*docx;*.jpg;", 
       //file_types_description : "All Files", 
       file_upload_limit : "1", 
       button_placeholder_id : "swfuploader", 
       button_image_url : "URL/file-browse.png", 
       button_width: 100, 
       button_height: 30, 
       upload_start_handler : uploadStart, 
       upload_success_handler : uploadSuccess 
      }); 
      //jobForm.form.submit(function(ev){ev.preventDefault()}) 
     }); 

     function uploadStart(){ 
      //.submit() 
      console.log(this,'start'); 
     }; 
     function uploadSuccess(){ 
      //form.submit() 
      console.log('success'); 
     } 
+1

당신이 의도적으로 주석나요 .submit()와 form.submit를) 다음

내 기능의 몇 가지 예입니다? –

+0

기능을 탐색하면서 SWFUpload의 핵심 기능에 영향을주지 않는 이벤트 함수입니다. 내가 모은 것에서 그들은 단지 그 사건들에 방아쇠를 당겨야 만한다. – Rell

답변

0

SWFUploadObj.startUpload();은 해고해야하며 POST 요청을 지정된 upload_url로 시작한 것입니다. 이 방법이 일부 기본 설정에 의해 해고되면 확실히 나를 위해 그것을하지 않았습니다.

// Bound to file_queued_handler : sets a flag that there is a file waiting to upload 
function swfuFileQueued(file){ 
    resumeQueued = true; 
    $j('#browseFile').val(file.name); 
} 


//Bound to form submit event: 
//a successful upload will submit this form again once the success response with the server-moved and renamed filename comes back from the file upload handling script 

function swfuFormSubmit(ev){ 
    if(uploadSuccess){ 
     return true; 
    } else { 
     if(resumeQueued == true){ 
      ev.preventDefault(); 
      swfuUploadStart(); // see next function 
     } else { 
      return true; 
     } 
    } 
} 

function swfuUploadStart(){ 
    try { 
     swfu.startUpload(); // <-- The actual method that begins the file upload request 
    } catch (e) { 
    } 
    return false; 
} 

function swfuProgress(){ ... 
function swfuError(){ ... 
function swfuSuccess(){ 
    //update input element containing filename or id to send with form 
    //update a status box with "Success" 
    //uploadSuccess = true 
    //form.submit() once more, this time uploadSuccess will tell the function to continue on and actually submit itself 

유용한 URL이 SWFUpload 과정 이해하기 : (http://www.dconstructing.com/2010/07/08/making-swfupload-work

0

은 2 단계로 진행됩니다 : 1. 당신은 당신이 실제 업로드를 시작하기 위해 양식을 제출해야합니다 (다음 입력 상자에 경로를 채 웁니다) 파일, (2)을 선택합니다. 당신이 파일을 선택한 후, 양식을 제출 한 후 //jobForm.form.submit(function(ev){ev.preventDefault()})

:

난 당신이 코드에서부터, 2 단계를 수행하지 않는 있으리라 믿고있어, 당신은 form.submit()

이 행의 주석을 해제하십시오 주석있다 .

+0

아쉽게도 선택 후 DOM에 입력이 삽입되지 않습니다. – Rell

+0

아니요, 오해입니다. "파일 선택"버튼에는 이미 숨겨진 입력이 포함되어 있습니다.이 입력은 사용자가 무언가를 선택한 후 파일 경로가있는 곳입니다. – Kristian

관련 문제