2012-10-07 8 views
0

파일과 함께 추가 양식 데이터를 보내고 있습니다. 다음은 폼 데이터입니다 : Uploadify 3.1 설정이 작동하지 않습니다.

 $(document).ready(function(){   
     $("#image_file").uploadify({ 
      'method' : 'post', 
      'queueSizeLimit' : 1, 
      'formData' : JSON.stringify(register_object), 
      'buttonText' : 'Profile Pic', 
      'auto' : false, 
      'multi' : false, 
      'swf' : 'js/plugins/others/uploadify.swf', 
      'uploader' : 'upload.ashx', 
      'fileTypeDesc': 'Image Files', 
      'fileTypeExts': '*.jpg;*.png;*.gif;*.bmp;*.jpeg', 
      'onUploadStart' : function(file) { 
       $('#file_upload').uploadify('settings', 'formData', JSON.stringify(register_object)); 
       alert(JSON.stringify(register_object)); 
      }, 
      'onUploadSuccess' : function(file,data) { 
       alert('The file finished processing. ' + data); 
      }, 
      'onUploadError' : function(file, errorCode, errorMsg, errorString) { 
       alert('The file ' + file.name + ' could not be uploaded: ' + errorString + ' ' + errorMsg); 
      } 
     });    
     $("#register").submit(function(){ 
      $('#input_password').val(CryptoJS.MD5($('#input_password').val())); 
      $('#repeat_password').val(CryptoJS.MD5($('#repeat_password').val())); 
     register_object['first_name']=$("#first_name").val(); 
     register_object['last_name']=$("#last_name").val(); 
     register_object['input_email']=$("#input_email").val(); 
     register_object['input_password']=$("#input_password").val(); 
     register_object['repeat_password']=$("#repeat_password").val(); 
      $("#image_file").uploadify('upload'); 
      return false; 
     }); 
    }); 

내가 서버에 포스트 데이터에 액세스

, 나는 아무것도 얻을 :

  register_object['first_name']=$("#first_name").val(); 
     register_object['last_name']=$("#last_name").val(); 
     register_object['input_email']=$("#input_email").val(); 
     register_object['input_password']=$("#input_password").val(); 
     register_object['repeat_password']=$("#repeat_password").val(); 

그리고, 다음 내가 사용하는 uploadify 코드입니다.

내가 뭘 잘못하고 있니?

답변

0

마지막으로 서버에 데이터를 가져올 수있었습니다. 먼저 $("#file_upload") 대신 $("#image_file") (0120)을 onUploadStart에 입력해야했습니다.

$('#image_file').uploadify("settings", "formData", {"first_name":register_object['first_name'],"last_name":register_object['last_name'],"input_email":register_object["input_email"],"input_password":register_object["input_password"],"repeat_password":register_object["repeat_password"]}); 

을 코드는 다음과 같이 간다 :

 $(document).ready(function(){   
     $("#image_file").uploadify({ 
      'method' : 'post', 
      'queueSizeLimit' : 1, 
      'formData' : JSON.stringify(register_object), 
      'buttonText' : 'Profile Pic', 
      'auto' : false, 
      'multi' : false, 
      'swf' : 'js/plugins/others/uploadify.swf', 
      'uploader' : 'upload.ashx', 
      'fileTypeDesc': 'Image Files', 
      'fileTypeExts': '*.jpg;*.png;*.gif;*.bmp;*.jpeg', 
      'onUploadStart' : function(file) {    
       **$('#image_file').uploadify("settings", "formData", {"first_name":register_object['first_name'],"last_name":register_object['last_name'],"input_email":register_object["input_email"],"input_password":register_object["input_password"],"repeat_password":register_object["repeat_password"]});** 
       alert(JSON.stringify(register_object)); 
      }, 
      'onUploadSuccess' : function(file,data) { 
       alert('The file finished processing. ' + data); 
      }, 
      'onUploadError' : function(file, errorCode, errorMsg, errorString) { 
       alert('The file ' + file.name + ' could not be uploaded: ' + errorString + ' ' + errorMsg); 
      } 
     });    
     .... 
    }); 
그리고 둘째로, 나는 onUploadStart 내에서 완전한 JSON 문자열을 써야했다
관련 문제