Jump to content

Search the Community

Showing results for tags 'inputfieldfile'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 3 results

  1. Hey all, I've looked at some other threads and github issues, but didn't find what I was looking for: https://processwire.com/talk/topic/21616-file-upload-inside-custom-module/ https://processwire.com/talk/topic/619-what-does-it-mean-destinationpath-is-empty-or-does-not-exist-upload_file/ https://github.com/processwire/processwire-issues/issues/885 I'm on PW version 3.0.165. I have a module using InputfieldFile to upload a CSV, then move it to a unique filename within a subdirectory in the module. Then it processes the CSV into a db table. That's actually all working smoothly, except I still get error messages on upload "destinationPath is empty or does not exist [field label]" and "Missing required value [field name]" Below is the relevant code. A couple notes: 1. I have both `required` and `requiredAttr` set because I wanted to avoid them clicking submit without selecting a file (it's happened, haha). I've tried turning those off and it fixes the second error "Missing required value" but not the first one about destinationPath 2. I can't seem to debug the $destination created by tempDir(), because I think it is removed when the request ends, but I presume it must be working OK because the CSV file ends up in the `/.uploads/` directory I specify, and is processed into a database table. 3. `/site/assets/cache/` directory is chmod 0777 and owned by "nobody" (yes, I know, I need to tighten this down :) Thanks for any assistance! Worst case I guess I can tell them to ignore the red message since it is actually working. <?php $destination = $this->files->tempDir($this)->get(); // debugging shows $destination = /site/assets/cache/WireTempDir/.ProcessMemberScorecard/0/ $form = $this->modules->get('InputfieldForm'); $form->attr('action', $this->page->url . 'upload-scores'); $form->attr('enctype', 'multipart/form-data'); $wrapper = new InputfieldWrapper(); $wrapper->importArray( [ [ 'type' => 'file', 'name' => 'scores_upload', 'label' => 'Scores File', 'description' => 'Select a CSV file to upload', 'required' => true, 'requiredAttr' => true, 'icon' => 'upload', 'extensions' => 'csv', 'destinationPath' => $destination, 'maxFiles' => 1, 'maxFilesize' => 10 * 1024 * 1024, 'noAjax' => true, 'descrptionRows' => 0, ], // additional checkbox fields, not relevant ] ); $form->append($wrapper); if ($this->input->requestMethod('POST')) { $form->processInput($this->input->post); $ul = new WireUpload('scores_upload'); $ul->setValidExtensions(['csv']); $ul->setMaxFiles(1); $ul->setOverwrite(true); $ul->setDestinationPath($this->config->paths($this) . '.uploads/'); $dt = new DateTime(); $tmpname = bin2hex(random_bytes(8)); $ul->setTargetFilename( sprintf('%s-%s.csv', $dt->format('Y-m-d'), $tmpname ) ); $results = $ul->execute(); if ($errors = $ul->getErrors()) { foreach ($errors as $error) { $this->error($error); } return $form->render(); } if (!$results) { // older, probably not needed since both required and requiredAttr are set $this->error('Please select a CSV file to upload'); return $form->render(); } // handle processing at this point, // then redirect to the next step where user confirms // the final result } .
  2. Hi Guys I have an Formbuilder Form which I am rendering on the frontend and also processing myself (I have checked the option "Submit to another URL (bypassing Form Builder processing)". I am also injecting a InputfieldFile Field "manually" with the form api to the fieldset object. The code looks like this: <?php namespace ProcessWire; $form = $forms->load("schaden-melden"); $inputfieldsform = $form->processor()->getInputfieldsForm(); $fieldsetSachverhalt = $inputfieldsform->find("name=sachverhalt"); $tempDir = wire()->files->tempDir('userUploads')->get(); $field = $modules->get("InputfieldFile"); $field->label = "Dateien hochladen"; $field->notes = "Maximal 10 Dateien, maximal 20 MB"; $field->required = 1; $field->attr("name+id", 'dateien'); $field->noCollapseItem = 1; $field->destinationPath = $tempDir; $field->extensions = "jpg jpeg gif png tif pdf"; $field->maxFiles = 10; $field->maxFilesize = 20*1024*1024; // 20mb foreach($fieldsetSachverhalt as $f) { $f->append($field); } $formFormBuilder = $forms->render($form); if($form->processor()->isSubmitted()){ $values = $form->processor()->getValues(); if($values['s_email'] == ""){ $p = new Page(); $p->template = 'damage-report-data'; $p->parent = $pages->get(1159); $p->name = session_id()."_".date("d-m-Y-H-i-s"); $p->sessionid = session_id(); $p->pd_anrede = $sanitizer->text($values['anrede']); $p->pd_vorname = $sanitizer->text($values['vorname']); $p->pd_nachname = $sanitizer->text($values['nachname']); $p->pd_strasse = $sanitizer->text($values['strasse']); $p->pd_hausnummer = $sanitizer->text($values['hausnummer']); $p->pd_plz = $sanitizer->int($values['plz']); $p->pd_ort = $sanitizer->text($values['ort']); $p->pd_telefon = $sanitizer->text($values['telefon']); $p->pd_policenummer = $sanitizer->text($values['policen_nr']); $p->pd_email = $sanitizer->email($values['e_mail']); $p->pd_eintrittsdatum = $sanitizer->text($values['eintrittsdatum_beginn_der_streitigkeit']); $p->pd_sachverhalt = $sanitizer->textarea($values['schadenmeldung_sachverhalt']); $p->pd_gegenpartei_adresse = $sanitizer->textarea($values['informationen_name_adresse_tel_etc']); $p->pd_reachable = $sanitizer->textarea($values['am_besten_erreichbar']); $p->contract_accepted = 1; $p->save(); $files = explode("|",$values['dateien']); foreach($files as $file){ if($file && file_exists($tempDir . $file)){ $currentSessionData->pd_files->add($tempDir . $file); } } $p->save(); session_regenerate_id(); $session->redirect($page->child("template=basic-page")->url); }else{ $out .= "Thank you, your form has been submitted."; $log->save("spams", json_encode(print_r($values, true))); } } else { $section = new \Sections($page); $section->injectForm($formFormBuilder); $out .= $section->renderSections(); } The Form itself is working and the files are also added to the pages I am creating. But the file field is not really user friendly at the moment. For example: 1. There is no option to delete the files when you have selected them from the disk: 2. When I select multiple files at once it only shows the first filename: 3. Lets say I send the form now and there are still errors in some other fields. The File Field is the rendered like in the processwire backend and the images are also lost (the files are linking to the page where the form/code itself is residing): 4. The valid extension property of the InputfieldFile is only working server side (means when form is send the files with the wrong filetype are just removed, but on the client side you can still upload for exmaple .doc files etc... When uploading file with false type nothing happens: When sending it removes the file: How can I adjust the File Field, that I can make the stuff above working just to my needs? I already needed to duplicate the InputfieldFile Module to the site folder because of some js error I was getting. I needed to make a change inside the InputfieldFile.js: I also must say that I don't know if the change above is also affecting the processwire backend in some way... I hope you can help me here out. PS: I know that the Formbuilder has it's own File Fieldtype but that File Fieldtype only works when the processing of the form is handled by the Formbuilder.
  3. Hey guys, I'm really really desperate for help at this stage, for my own sanity mostly. I've been trying to set up a form that requires several fields one of which is a file upload, the user can upload max 10 files with extension jpg/png/jpeg and these are sent to the admin email as attachments. Currently this i am using the InputfieldFile module, I have moved it over to /site/modules because hooking the return html wasn't enough for my needs. So basically I have this. $images = $modules->get("InputfieldFileCustom"); $images->attr('label', "Upload your images"); $images->required = 0; $images->maxFiles = 10; $images->attr('id+images','image'); $images->attr('placeholder','no file selected'); $images->attr('extensions','jpg'); $form->append($images); I expected output that would allow me to upload and delete files. Except right now my biggest issue is the fact that the remove button isn't being displayed because the ___renderItem method isn't being run and I have no idea how to make this work. I'm going to have to do a lot of fun stuff with the markup for the majority of the render methods but I can't do anything until I get the remove button to display. I also made a inputfieldfilecustom.js which is imported on the page. I've renamed all instances of InputFieldFile to InputFIeldFileCustom (in both js and module) Begging for help around now. it would be incredibly appreciated if someone can give me any direction.
×
×
  • Create New...