changing file name of single upload file before saving to server folder

Home › Forums › Quform PHP › changing file name of single upload file before saving to server folder

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

    I am using Quform to upload a pdf file to a folder on the server. All that is working, but I now need to change the name of the file prior to saving to the server folder. I am having difficulty in how to achieve this in the process.php file. I am placing the code in the Custom code section #1.
    Here is my current attempt:

    
            // Custom code section #1 - see documentation for examples
                   
            $temp = explode(".", $_FILES["file"]["name"]);
            $acronym = $form->getValue('ho_acronym');
            $hotype = $form->getValue('ho_type');
            $newfilename = $acronym . $hotype . '.' . end($temp);
    
            // End custom code section #1
    
    
       //Process single upload field
                            if ($file['error'] === UPLOAD_ERR_OK) {
                                $fileData = array(
                                    'path' => $file['tmp_name'],
                                    //'filename' => Quform_Element_File::filterFilename($file['name']),
                                    'filename' => $newfilename,
                                    'type' => $file['type'],
                                    'size' => $file['size']
    

    Am I on rhe right tract?

    #28943
    waubain
    Participant

    I got this working. The file name retained the .pdf without adding it back, so I was getting an additional period at the end.

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