Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass a spooled file, uploaded from a file upload widget, to a C FILE *f pointer
    primarykey
    data
    text
    <p>I need to pass some text files, uploaded from a Wt file upload widget, as arguments to some C function for processing their data. Unless that I really can't find a proper way to open a file using the spooled file name (converted from std::string to a char *) as the first fopen()'s argument, I realized that I have not understood the file handling methods provided by Wt. I.e., where a spooled file is stored?. I tried to use <code>std::string WtFileUpload::spoolFileName() const</code> just after the file upload is finished (I provide a button to be clicked when the progress bar reaches the end), but by digging the errno number, I found that the file didn't exists.</p> <p>Please, suggest me a proper way to proceed on this (provide some code if you can) and help me to understand the way Wt handles files uploaded with this widget.</p> <p>Thanks in advance.</p> <p><strong>UPDATE</strong>: My file upload and handling code:</p> <pre><code>//Declared in the application class: Wt::WFileUpload *RORUpload; Wt::WPushButton *RORUploadButton; //Create file upload widget and add handlers for it in application constructor: root()-&gt;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-&gt;setFileTextSize(40); root()-&gt;addWidget(new Wt::WText("RINEX Rover Observation Data ")); new Wt::WBreak(root()); RORUploadButton = new Wt::WPushButton("Upload", root()); root()-&gt;addWidget(RORUpload); //Upload when the button is clicked. RORUploadButton-&gt;clicked().connect(RORUpload, &amp;Wt::WFileUpload::upload); RORUploadButton-&gt;clicked().connect(RORUploadButton, &amp;Wt::WPushButton::disable); // Upload automatically when the user entered a file. RORUpload-&gt;changed().connect(RORUpload, &amp;Wt::WFileUpload::upload); // !!! do not rename this 'upload' RORUpload-&gt;changed().connect(RORUploadButton, &amp;Wt::WPushButton::disable); // React to a succesfull upload. RORUpload-&gt;uploaded().connect(RORUpload, (Wt::WObject::Method) &amp;Wt::WFileUpload::uploaded); //React to a fileupload problem. RORUpload-&gt;fileTooLarge().connect(RORUpload, (Wt::WObject::Method) &amp;Wt::WFileUpload::fileTooLarge); //When user presses a "submit" button, a connection function will be called. const std::string Nameofror = RORUpload-&gt;spoolFileName(); const char *CNameofror = Nameofror.c_str(); </code></pre> <p>I wonder if the problem is related with my (Wt::WObjectMethod) cast. <strong>EDIT</strong>: See my comment on this question.</p> <p><strong>UPDATE 2</strong>: Forgot to say that i get a program crash when I click the "submit" button Code for this:</p> <pre><code>//Create button into application constructor: SubmitButton = new Wt::WPushButton("Submit", root()); SubmitButton-&gt;clicked().connect(SubmitButton, &amp;Wt::WPushButton::disable); SubmitButton-&gt;clicked().connect(this, &amp;GOPApplication::definedOptions); //definedOptions: void GOPApplication::definedOptions() { int Posmode = PTGroup-&gt;checkedId(); //Value selection from PTContainer (checked radio button id). //int singlemoving; //Value selection from SPContainer (checked radio button id). int Frequencies = FGroup-&gt;checkedId(); //Value selection from FContainer (checked radio button id). const Wt::WString WElmask = EMedit-&gt;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-&gt;checkedId(); //Value selection from HContainer (checked radio button id). int Soltype = STGroup-&gt;checkedId(); //Value selection from STContainer (checked radio button id). int Sateph = SAGroup-&gt;checkedId(); //Value selection from SEContainer (checked radio button id). int Basestatcoord = BSCGroup-&gt;checkedId(); //Value selection from BSCContainer (checked radio button id). int Ionerror = IEGroup-&gt;checkedId(); //Value selection from IEContainer (checked radio button id). int Troperror = TEGroup-&gt;checkedId(); //Value selection from TEContainer (checked radio button id). int Receiverapcpvc = RAGroup-&gt;checkedId(); //Value selection from RAContainer (checked radio button id). int Satelliteapvc = SAGroup-&gt;checkedId(); //Value selection from SAContainer (checked radio button id). int Earthtidescorr = ETCGroup-&gt;checkedId(); //Value selection from ETCContainer (checked radio button id). int Ambresstr = STRGroup-&gt;checkedId(); //Value selection from STRContainer (checked radio button id). const Wt::WString WMinlockcount = MLCedit-&gt;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-&gt;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-&gt;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-&gt;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-&gt;checkedId(); //Value selection from STSContainer (checked radio button id). int Outputresiduals = ORGroup-&gt;checkedId(); //Value selection from ORContainer (checked radio button id). int Settimeformat = STFGroup-&gt;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-&gt;spoolFileName(); const char *CNameofror = Nameofror.c_str(); printf("\n\n============= %s =============\n\n", CNameofror); //const std::string Nameofrob = ROBUpload-&gt;spoolFileName(); //const char *CNameofrob = Nameofrob.c_str(); //const std::string Nameofrn = RNUpload-&gt;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); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload