2010-07-21 2 views
2

PHP로 업로드하는 이미지에 Jquery Uploadify를 사용하고 있습니다. 여기에는 uploadify 인스턴스가 여러 개 있으며 각 인스턴스마다 다른 폴더에 이미지를 업로드하고 있습니다.Jquery 이미지를 여러 인스턴스를 Uplaodify하고 이전 인스턴스의 각 인스턴스를 호출합니다.

나는 uplaodify의 두 번째 인스턴스에서 업로드 된 이미지를 업로드 한 첫 번째 인스턴스를 업로드 한 후에 만 ​​이미지를 업로드하려고합니다.

$ ('# listing_image'). uploadifySettings ('folder', 'listing_image_TempImage'); $ ('# listing_image'). uploadifyUpload(); $ ('# listing_image1'). uploadifySettings ('폴더', 'listing_image1_TempImage'); $ ('# listing_image1'). uploadifyUpload();

'listing_image1'처리가 완료되면 'listing_image1'이 (가) 전화를받습니다. 어떻게이 동작을 얻을 수 있습니까 ??

답변

1

아직 답변을 드릴 수 없습니다. 그래서 저는 대신 여기에 쓰고 있습니다.

봅니다이를 이용하여 하나의 업로드 작업을 (링크가 올바른 위치에의 지점 확인)하기 : 당신이 그 일을 얻을 수있을 때, 당신은이 일을 할 수 있어야한다

$('#listing_image').uploadify({ 
    'uploader' : 'uploadify.swf', 
    'script' : 'uploadify.php', 
    'cancelImg' : 'cancel.png', 
    'folder' : '/listing_image_TempImage', 
    onComplete: function(){ 
     // Do oncomplete stuff. 
    } 
}); 

.

var uploads = [2,4,5]; // Only number 2,4 and 5 
var numberofuploads = uploads.length; // How many is that? 
var folderlist = [0, '/folder1', '/folder2', '/folder3', '/folder4', '/folder5', '/folder6']; // List of folders to upload to 
var listingimageslist = [0, '#listing_image1', '#listing_image2', '#listing_image3', '#listing_image4', '#listing_image5', '#listing_image6']; // List of form selectors. 

var folder = folderlist[uploads[0]]; // What folder should this form upload to 
var listingimages = listingimageslist[uploads[0]]; // With what selector can the form be found? 
if (numberofuploads > 1) 
{ 
    var next = 1; // What upload to initiate after this one? 
} 
initUpload(listingimages,folder); // make the upload thing work. 


function initUpload(e,folder) 
{ 
    $(e).uploadify({ 
     'folder' : folder, 
     'uploader' : 'uploadify.swf', 
     'script' : 'uploadify.php', 
     'cancelImg' : 'cancel.png', 
     onComplete: function(){ 
      var folder = folderlist[uploads[next]]; 
      var listingimages = listingimageslist[uploads[next]]; 
      next++ 
      if (numberofuploads != next) 
      { 
       initUpload(listingimages,folder); 
      } 
     } 
    }); 
}; 

코드를 테스트하지 않았지만 자바 스크립트가 약간있는 경우 제대로 작동 할 수 있어야합니다.

Remenber는 $ (문서)의 모든 jQuery 코드를 다음과 같이 .ready하기 : 답변

$(document).ready(function() { 
// Insert code here 
}); 
+0

대단히 감사합니다 Webbies하지만 여기에 문제가 하나 있는데 .... 처음 두 인스턴스를 확인했지만이 코드는 처음 2 인스턴스의 이미지를 uplaoding하지 않습니다 ... $ ('# listing_image'). uploadify ({ 'folder' : '/ listing_image_TempImage', onComplete : function() {$ ('# listing_image1'). – Shatru

+0

이 답변에서 제공 한 첫 번째 코드 스 니펫을 사용하여 단 하나의 작업을 수행하십시오. – Webbies

2

첫 번째 업로드가 완료되면 실행되는 "콜백"기능을 만들 수 있습니다. 6

$('#listing_image').uploadify({ 
'folder' : '/listing_image_TempImage', 
onComplete: function(){ 
    $('#listing_image1').uploadify({ 
    'folder' : '/listing_image_TempImage' 
    }); 
} 
}); 

(하나씩) 업로드 :

$('#listing_image').uploadify({ 
    'folder' : '/listing_image_TempImage', 
    onComplete: function(){ 
     $('#listing_image1').uploadify({ 
      'folder' : '/listing_image_TempImage1', 
      onComplete: function(){ 
       $('#listing_image2').uploadify({ 
        'folder' : '/listing_image_TempImage2', 
        onComplete: function(){ 
         $('#listing_image3').uploadify({ 
          'folder' : '/listing_image_TempImage3', 
          onComplete: function(){ 
           $('#listing_image4').uploadify({ 
            'folder' : '/listing_image_TempImage4', 
            onComplete: function(){ 
             $('#listing_image5').uploadify({ 
              'folder' : '/listing_image_TempImage5' 
             }); 
            } 
           }); 
          }   
         }); 
        } 
       }); 
      } 
     }); 
    } 
}); 

나는 당신이 얘기 this uploadify를 있다고 가정합니다.

사용할 수있는 콜백의 전체 목록은 look in the docs입니다.

+0

감사합니다. 네, 저는 같은 uplaodify에 대해 이야기하고 있습니다 ... 여기에 6 인스턴스의 uploadify가있어서 모든 6 인스턴스에 대해 "콜백"을 구현할 수 있습니까 ??? 예제가 2 인스턴스 만 작동합니다. – Shatru

+0

당신은 그들 모두를 하나씩 가지고있는 것에 대해 이야기하고 있습니다. 따라서 다섯 번째는 네 번째 완료 후에 만 ​​실행됩니까? – Webbies

+0

네, 정확히 어떻게 이것을 할 수 있습니까? – Shatru

0

세션을 사용하는 경우 스크립트 실행이 서버 측에서 지연되어 각 업로드가 차례로 처리됩니다.

+0

안녕 Pekka, 실제로 지금 요구 사항이 변경되었습니다 ... 이제 우리는 Uploadify의 6 인스턴스를 가지고 있으며 각 인스턴스는 업로드 된 이미지가 업로드 될 고정 된 폴더를 갖게됩니다. 여기서는 uplaodify의 두 번째 인스턴스가 uploadify의 첫 번째 인스턴스를 처리 할 때만 호출하기를 원합니다. 감안할 때 코드 이미지 $ ('#의 listing_image')을 uplaoding되지 않는다 ({ '폴더'uploadify :. '/ listing_image_TempImage'를 onComplete를 :. 함수() { $은 ('#의 listing_image1')는 {(uploadify '폴더': '/ listing_image_TempImage' }); } }); – Shatru

관련 문제