Project

General

Profile

Wt::WFileUpload not Working with ISAPI and IIS

Added by Patrick ottavi about 5 years ago

Hello,

I have a problem with wt::WFileUpload,

I can not download a file when the site runs under IIS with the ISAPI connector.

the same site in whttp mode works very well,

I thought a problem of access right on the temporary windows directory but nothing helps.

after calling the upload () function the process remains frozen.

I use wt 4.1.2 with IIS under windows 10.

If anyone had an idea of the problem, I would be happy.

Regards Patrick.

my portion code:

      pDialogPhoto = new WDialog(L"Photo");
      pDialogPhoto->contents()->addWidget(Wt::cpp14::make_unique<WText>(L"<p>Téléchargement Photo</p>"));
      Wt::WFileUpload* fu = pDialogPhoto->contents()->addWidget(Wt::cpp14::make_unique<Wt::WFileUpload>());
      fu->setProgressBar(Wt::cpp14::make_unique<Wt::WProgressBar>());
      fu->setMargin(10, Side::Right);
      fu->setFileTextSize(500000);

    pDialogPhoto->setClosable(true);
    pDialogPhoto->setResizable(false);
    pDialogPhoto->rejectWhenEscapePressed(true);
    pDialogPhoto->done(Wt::DialogCode::Accepted);

    WPushButton* BtEnd = pDialogPhoto->footer()->addWidget(Wt::cpp14::make_unique<WPushButton>(L"Fermer"));
    BtEnd->clicked().connect(pDialogPhoto, &WDialog::accept);
    BtEnd->addStyleClass("btn-success");

    fu->changed().connect([=]
    {
        OutputDebugStringA("Start Upload File");
        OutputDebugStringA(fu->spoolFileName().c_str());
        fu->upload();
    });

    fu->uploaded().connect([=]
    {
    fu->progressBar()->setValue(fu->progressBar()->maximum());
    string spath = m_pApp->GetDosImgPath()+m_ComboSite->currentText().toUTF8();
    ::CreateDirectoryA(spath.c_str(), NULL);
    spath +="\\";
    string sName = spath+ WString("Photo{1}-{2}.png").arg(m_nChrono).arg(m_nPartPhoto).toUTF8();                    
    CopyFileA(fu->spoolFileName().c_str(), sName.c_str(), FALSE);
    m_aImages.push_back(sName);
    });

    fu->fileTooLarge().connect([=]
    {
    OutputDebugStringA("Fichier trop large");
    });

    pDialogPhoto->finished().connect(this, &FormAcceuil::DialogDonePhoto);
    pDialogPhoto->show();

Replies (1)

RE: Wt::WFileUpload not Working with ISAPI and IIS - Added by Patrick ottavi about 5 years ago

I complete my post, looking in the sources I found the function getTempDir which gives the name of the temporary file to create,

I modified it to make appear the name in DebugView Program,

the treatment does not arrive until, the blocking is before the creation of the file.

Regards Patrick.

std::string getTempDir()
    {
      std::string tempDir;

      char *wtTmpDir = std::getenv("WT_TMP_DIR");
//....
#ifdef WT_WIN32
      char tmpName[MAX_PATH];

      if(tempDir == "" 
     || GetTempFileNameA(tempDir.c_str(), "wt-", 0, tmpName) == 0)
    return "";
      OutputDebugString(tmpName);
      return tmpName;
#else
    (1-1/1)