2013-04-01 128 views
5

我想實現一個窗體上傳文件,但開始做操作,當我點擊一個提交按鈕,問題是有一個奇怪的錯誤,我不知道什麼是它,我做了教程的例子,它的工作沒有問題,現在我實現相同,但與index.html,它不工作。按鈕提交R與閃亮

的錯誤是: 「錯誤的,如果(輸入$ uploadFasta == 0)返回(NULL): 參數爲長度爲零的」

我的index.html像:

<form class="span12 menu-med-upload"> 
    <div class="row-fluid"> 
     <center> 
      <div class="custom-input-file btn btn-inverse"> 
      <input type="file" size="1" id="fileFasta" class="input-file" /> 
      </div> 
     </center> 
     <button id="uploadFasta" type="button" class="btn action-button shiny-bound-input" >go!</button> 
    </div> 
</form> 

我server.R是這樣的:

output$table <- renderText({ 
    if(input$uploadFasta == 0) 
     return(NULL) 
    myRenderTable() 
}) 

有人知道出了什麼問題,並感謝所有和抱歉,如果這個話題是之前開放的,但我找不到。

回答

2

動作按鈕是一個自定義輸入綁定,我敢打賭它沒有被加載。

在同一目錄server.R添加global.R文件,並將它包含此:

addResourcePath(
    prefix='actionbutton', 
    directoryPath=system.file('actionbutton', 
          package='shinyIncubator')) 

然後在你的index.html,添加以下<head>

<script src="actionbutton/actionbutton.js"></script> 

(一如既往,一定要有明確的關閉</script>標籤 - 不要使用<script />。)