2010-04-16 52 views
0

我想用HTML5運行時上傳一個plupload文件。與webpy的plupload

這是我的HTML/JS代碼:

jQuery(function(){ 
    jQuery("#uploader").pluploadQueue({ 
     // General settings 
     runtimes : 'html5', 
     name : 'file', 
     url : 'http://server.name/addContent', 
     max_file_size : '${maxSize}$_("GB")', 
    }); 


    jQuery('#form_upload_file').submit(function(e) { 
     var uploader = jQuery('#uploader').pluploadQueue(); 
     // Validate number of uploaded files 
     if (uploader.total.uploaded == 0) { 
      // Files in queue upload them first 
      if (uploader.files.length > 0) { 
       // When all files are uploaded submit form 
       uploader.bind('UploadProgress', function() { 
       if (uploader.total.uploaded == uploader.files.length) 
        jQuery('#form_upload_file').submit(); 
       }); 
       uploader.start(); 
      } else 
       alert('You must at least upload one file.'); 

      e.preventDefault(); 
     } 
    }); 


}); 

<form id="form_upload_file" action="#" method="POST"> 
     <div id="uploader"></div> 
     <input type="hidden" name="token" value="token" /> 
     <input type="hidden" name="idUser" value="$idUser" /> 
    </form> 

所以,當我在點擊按鈕來上傳(提交()方法不叫),它的OPTIONS HTTP請求到我的服務器 所以我不知道我必須做什麼來保存文件?

這是我webpy代碼:

def OPTIONS(self): 
     web.header('Content-type', 'text/plain: charset=utf-8') 
     web.header('Cache-Control', 'no-store, no-cache, must-revalidate') 
     web.header('Cache-Control', 'post-check=0, pre-check=0', False) 
     web.header('Pragma', 'no-cache') 


    def POST(self): 
     input = web.input(_unicode=False, file={})#on récupère les input 
     self.copy(input.file.file) 
     etc. 

任何想法有什麼不好?

+0

相關:http://www.plupload.com/punbb/viewtopic.php?id=50 – 2011-04-11 18:05:01

回答