Multi File Uploads – Saving File Names Into DB

Home Forums Quform PHP Multi File Uploads – Saving File Names Into DB

This topic is: resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18899
    davidjwest
    Participant

    Hi – first thanks for a great script, saved me a lot of work!

    I am having trouble getting the file names saved using multi uploads.

    1. The uploads are working OK, they are getting uploaded to the correct location.

    2. The database script is working, it is saving the correct info etc.

    But I cannot work out how to get the filenames to save.

    This is my code:

    (this is the form code, all uploads are called uploads[])

    ‘<div class=”quform-input-file”>
    <input type=”file” name=”uploads[]” />
    </div>’

    This is in process.php (my db field is called image)

    ‘$upload = $form->getValue(‘upload’);
    $uploadUrl = isset($upload[0][‘url’]) ? $upload[0][‘url’] : ”;

    /* Step 3: configure the data to save */
    $data = array(
    ‘title’ => $form->getValue(‘title’),
    ‘description’ => $form->getValue(‘description’),
    ‘category’ => $form->getValue(‘category’),
    ‘image’ => $uploadUrl,
    );’

    I want all the image names in that field, ideally separated with a comma or something like that.

    • This topic was modified 8 years, 6 months ago by davidjwest.
    #18901
    davidjwest
    Participant

    I have found a rather unorthodox solution, but my initial test seems to show it works.

    I just added a line to your attachment code that sends the confirmation email:


    // Add any attachments
    foreach ($attachments as $attachment) {
    $mailer->addAttachment($attachment[‘path’], $attachment[‘filename’], ‘base64’, $attachment[‘type’]);

    $filenames = $filenames . $attachment[‘filename’] . “|”;

    }

    And then inserted that into the DB, I had to move your mailer code above the code that writes the data to the table so it had the value ready.

    Just in case this helps anyone. Thanks.

    (The pipe is what I am using the delimit the data)

    • This reply was modified 8 years, 6 months ago by davidjwest.
    #18907
    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.

    • This reply was modified 8 years, 6 months ago by Ally.
    #18912
    davidjwest
    Participant

    Thanks – my solution is working but appreciate your time as your solution is more logical!

Viewing 4 posts - 1 through 4 (of 4 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