Capture file name of uploaded file

Home Forums Quform PHP Capture file name of uploaded file

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29078
    waubain
    Participant

    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.

    #29085
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #29091
    waubain
    Participant

    I 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

    #29093
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #29099
    waubain
    Participant

    That worked thank you.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy