Home › Forums › Quform PHP › Capture file name of uploaded file
- This topic has 4 replies, 2 voices, and was last updated 5 years, 7 months ago by waubain.
- AuthorPosts
- April 16, 2019 at 1:00 pm #29078waubainParticipant
I am trying to capture the name of the file that is being uploaded to save in a array. The Quform element is named ‘upload’, but that is not working when I use it in the =>getValue statement.
$upload = new Quform_Element_File('upload'); $form->addElement($upload); $filename = $form->getValue('upload');
How do I access the name of the file being uploaded. Thanks.
April 16, 2019 at 4:58 pm #29085AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
April 17, 2019 at 1:32 pm #29091waubainParticipantI am still having a problem. The filename value in the new array of form inputs are showing a NULL for the filename. I am using the single file upload.
“filename”:null
All of the other form elements are populating the new array as expected. Does the array need to be decoded or parsed?
this is my code
/** Custom code section #1 - see documentation for examples **/ //Capture form input values $ho_meetdate = $form->getValue('meetingdate'); $ho_acronym = $form->getValue('ho_acronym'); $ho_type = $form->getValue('ho_type'); //get uploaded file name $files = $form->getValue('upload'); $ofilename = ($files[0]['filename']); //Rename uploaded file $newfilename = $ho_acronym . $ho_type; //Create new array if does not exist or append if exists $arr_file = array(); $arr_file['meetdate'] = $ho_meetdate; $arr_file['acronym'] = $ho_acronym; $arr_file['type'] = $ho_type; $arr_file['ofilename']= $ofilename; $arr_file['nfilename']= $newfilename; //Save the JSON string to a text file. $ho_encoded = json_encode($arr_file); file_put_contents("../../editor/handout_arrayTest.txt", $ho_encoded); /** End custom code section #1 **/
Array contents = {“meetdate”:”2019-05-02″,”acronym”:”aa”,”type”:”_ho_1c.pdf”,”ofilename”:null,”nfilename”:”aa_ho_1c.pdf”}
Thank you for your help
April 17, 2019 at 2:12 pm #29093AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
April 18, 2019 at 2:00 pm #29099waubainParticipantThat worked thank you.
- AuthorPosts
- You must be logged in to reply to this topic.