J
J
JustCoder2014-03-21 18:02:33
Python
JustCoder, 2014-03-21 18:02:33

Python - PyQt4 (Webkit) How to populate an input(type="file" multiple="") field?

I am trying to upload a file via a form

<form action="#">
    Select a file: <input type="file" id="photos_upload_input" multiplie="">
    <input type="submit">
</form>

, using QWebPage .
class WebPage(QWebPage):
    def __init__(self, parent = None):
        QWebPage.__init__(self)
        self.overrideUpload = None

    def extension(self, extension, option, output):
        '''
        The behavior of this function is determined by extension . 
        The option and output values are typically casted to the corresponding types (for example, 
        ChooseMultipleFilesExtensionOption and ChooseMultipleFilesExtensionReturn for ChooseMultipleFilesExtension )
        '''
        ...?
        if self.overrideUpload is None:
            return super(WebPage, self).extension(self, extension, option, output)
        result = self.overrideUpload
        ....?

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JustCoder, 2014-03-22
@JustCoder

The issue was resolved like this:

...
def extension(self, extension, option, output):
    if (extension == self.ChooseMultipleFilesExtension):
        if self.overrideUpload is None:
            return super(WebPage, self).extension(self, extension, option, output)
        file_upl = self.overrideUpload
        self.overrideUpload = None
        output.fileNames = QStringList([file_upl])
        return True
    return False
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question