cryostar Posted June 18, 2021 Share Posted June 18, 2021 Hello! I created an admin page that allows a batch record insert/update via uploading a csv file. I was able to read the file using the following: protected function ___processUploadBatchRecord(InputfieldForm $form) { //called from an admin page ___executeUploadRecords $form->processInput($this->input->post); $pageFile = $form->get('order_record')->value; $destPath = $form->get('order_record')->destinationPath; $file = fopen($destPath.$pageFile,"r"); $headers = fgetcsv($file, 0, ','); $orders = array(); while ($row = fgetcsv($file, 0, ',')){ $orders[] = array_combine($headers, $row); } //TODO: Create a new page to store these values } The problem is processInput is storing the csv file in the system, which I don't want because it's a file that should be discarded after reading through it. Is this correct? I was thinking of accessing $_FILE variable but I don't know if that's a good practice in processwire. Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 18, 2021 Share Posted June 18, 2021 I regularly use the ImportPagesCSV module and upload around 3-5 files each week. Right now none of these files exists anymore in the filesystem. Therefore I looked into the module and it uses $files->unlink() Here is a link to that line via Github: https://github.com/ryancramerdesign/ImportPagesCSV/blob/93fa3f1110be5b51b50c5f903d1d182a20565b26/ImportPagesCSV.module#L441 Maybe that helps a bit. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now