2012-01-15 17 views
1

を返す私はwebpy料理に応じた形でポップアップを作成するスクリプトがあります。入力[タイプ=ファイル]が空の値に

:私のpythonアプリで

jQuery('#logo').click(function(){ 
    var content = ('<h1>Upload logo</h1>' + 
     '<form method="POST" enctype="multipart/form-data" action="/upload">' + 
     '<input type="file" id="myfile" accept="image/jpeg,image/png,image/gif" />' + 
     '<button id="upload" type="submit">Загрузить</button></form>' 
     ); 
    popup(content); 
}); 

を私は、関連するクラスのための簡単なコードを持っています

class uploadPage(allpages): 
    def POST(self): 
     x = web.input(myfile={}) 
     print x 

ファイルをアップロードしようとすると、私は常に空のストレージオブジェクトを取得します。

答えて

1

要素<input type="file" />には、フォーム提出のファイル名を示すname属性はありません。 1つのフォームに複数の入力フィールド(fileなど)を含めることができるため、名前が必要です。 name=を追加すると、問題が解決するはずです。

'<input type="file" name="myfile" id="myfile" accept="image/jpeg,image/png,image/gif" />' 
//     ^^^^^^^^^^^^^ 
関連する問題