Wt ファイル アップロード ウィジェットからアップロードされたテキスト ファイルを、データを処理するための C 関数に引数として渡す必要があります。スプールされたファイル名 (std::string から char * に変換されたもの) を最初の fopen() の引数として使用してファイルを開く適切な方法を本当に見つけられない限り、私は、 Wtによって提供されるファイル処理方法。つまり、スプール・ファイルはどこに保管されますか? std::string WtFileUpload::spoolFileName() const
ファイルのアップロードが完了した直後に使用しようとしましたが(プログレスバーが最後に達したときにクリックするボタンを提供しています)、errno番号を掘り下げると、ファイルが存在しないことがわかりました。
これを進めるための適切な方法を提案し (可能であればコードを提供してください)、Wt がこのウィジェットでアップロードされたファイルを処理する方法を理解するのを手伝ってください。
前もって感謝します。
更新:私のファイルのアップロードと処理コード:
//Declared in the application class:
Wt::WFileUpload *RORUpload;
Wt::WPushButton *RORUploadButton;
//Create file upload widget and add handlers for it in application constructor:
root()->addWidget(new Wt::WText("RINEX File Loaders "));
new Wt::WBreak(root());
//RINEX observation data file from rover station uploader.
new Wt::WBreak(root());
RORUpload = new Wt::WFileUpload();
RORUpload->setFileTextSize(40);
root()->addWidget(new Wt::WText("RINEX Rover Observation Data "));
new Wt::WBreak(root());
RORUploadButton = new Wt::WPushButton("Upload", root());
root()->addWidget(RORUpload);
//Upload when the button is clicked.
RORUploadButton->clicked().connect(RORUpload, &Wt::WFileUpload::upload);
RORUploadButton->clicked().connect(RORUploadButton, &Wt::WPushButton::disable);
// Upload automatically when the user entered a file.
RORUpload->changed().connect(RORUpload, &Wt::WFileUpload::upload); // !!! do not rename this 'upload'
RORUpload->changed().connect(RORUploadButton, &Wt::WPushButton::disable);
// React to a succesfull upload.
RORUpload->uploaded().connect(RORUpload, (Wt::WObject::Method) &Wt::WFileUpload::uploaded);
//React to a fileupload problem.
RORUpload->fileTooLarge().connect(RORUpload, (Wt::WObject::Method) &Wt::WFileUpload::fileTooLarge);
//When user presses a "submit" button, a connection function will be called.
const std::string Nameofror = RORUpload->spoolFileName();
const char *CNameofror = Nameofror.c_str();
問題は私の (Wt::WObjectMethod) キャストに関連しているのでしょうか。編集:この質問に関する私のコメントを参照してください。
更新 2 :「送信」ボタンをクリックするとプログラムがクラッシュすることを忘れていました。これのコード:
//Create button into application constructor:
SubmitButton = new Wt::WPushButton("Submit", root());
SubmitButton->clicked().connect(SubmitButton, &Wt::WPushButton::disable);
SubmitButton->clicked().connect(this, &GOPApplication::definedOptions);
//definedOptions:
void GOPApplication::definedOptions()
{
int Posmode = PTGroup->checkedId(); //Value selection from PTContainer (checked radio button id).
//int singlemoving; //Value selection from SPContainer (checked radio button id).
int Frequencies = FGroup->checkedId(); //Value selection from FContainer (checked radio button id).
const Wt::WString WElmask = EMedit->text(); //Value selection from EMw (given number).
std::string SElmask = WElmask.narrow(); //Value selection from EMw (given number).
const char *CElmask = SElmask.c_str(); //Value selection from EMw (given number).
float Elmask = atof(CElmask); //Value selection from EMw (given number).
int Height = HGroup->checkedId(); //Value selection from HContainer (checked radio button id).
int Soltype = STGroup->checkedId(); //Value selection from STContainer (checked radio button id).
int Sateph = SAGroup->checkedId(); //Value selection from SEContainer (checked radio button id).
int Basestatcoord = BSCGroup->checkedId(); //Value selection from BSCContainer (checked radio button id).
int Ionerror = IEGroup->checkedId(); //Value selection from IEContainer (checked radio button id).
int Troperror = TEGroup->checkedId(); //Value selection from TEContainer (checked radio button id).
int Receiverapcpvc = RAGroup->checkedId(); //Value selection from RAContainer (checked radio button id).
int Satelliteapvc = SAGroup->checkedId(); //Value selection from SAContainer (checked radio button id).
int Earthtidescorr = ETCGroup->checkedId(); //Value selection from ETCContainer (checked radio button id).
int Ambresstr = STRGroup->checkedId(); //Value selection from STRContainer (checked radio button id).
const Wt::WString WMinlockcount = MLCedit->text(); //Value selection from MLCw (given number).
std::string SMinlockcount = WMinlockcount.narrow(); //Value selection from MLCw (given number).
const char *CMinlockcount = SMinlockcount.c_str(); //Value selection from MLCw (given number).
float Minlockcount = atof(CMinlockcount); //Value selection from MLCw (given number).
const Wt::WString WMinfixcount = MFCedit->text(); //Value selection from MFCw (given number).
std::string SMinfixcount = WMinfixcount.narrow(); //Value selection from MFCw (given number).
const char *CMinfixcount = SMinfixcount.c_str(); //Value selection from MFCw (given number).
float Minfixcount = atof(CMinfixcount); //Value selection from MFCw (given number)
const Wt::WString WThreshold = Tedit->text(); //Value selection from Tw (given number).
std::string SThreshold = WThreshold.narrow(); //Value selection from Tw (given number).
const char *CThreshold = SThreshold.c_str(); //Value selection from Tw (given number).
float Threshold = atof(CThreshold); //Value selection from Tw (given number).
const Wt::WString WMinelevangle = MEAedit->text(); //Value selection from MEAw (given number).
std::string SMinelevangle = WMinelevangle.narrow(); //Value selection from Tw (given number).
const char *CMinelevangle = SMinelevangle.c_str(); //Value selection from Tw (given number).
float Minelevangle = atof(CMinelevangle); //Value selection from Tw (given number).
int Settimesystem = STSGroup->checkedId(); //Value selection from STSContainer (checked radio button id).
int Outputresiduals = ORGroup->checkedId(); //Value selection from ORContainer (checked radio button id).
int Settimeformat = STFGroup->checkedId(); //Value selection from STFContainer (checked radio button id).
//What about RINEX files obtaining?
//Maybe... (see notebook for infos about spoolFileName() usage)
const std::string Nameofror = RORUpload->spoolFileName();
const char *CNameofror = Nameofror.c_str();
printf("\n\n============= %s =============\n\n", CNameofror);
//const std::string Nameofrob = ROBUpload->spoolFileName();
//const char *CNameofrob = Nameofrob.c_str();
//const std::string Nameofrn = RNUpload->spoolFileName();
//const char *CNameofrn = Nameofrn.c_str();
//post-processing(Posmode,Frequencies,Elmask,Height,Soltype,Sateph,Basestatcoord,Ionerror,Troperror,Receiverapcpvc,
// Satelliteapvc,Earthtidescor,Ambresstr,Minlockcount,Minfixcount,Threshold,Minelevangle,Settimesystem,Outputresiduals,Settimeformat);
}