store file upload on my server using php

  • Profile Image
    milbra
    Asked on February 20, 2014 at 11:57 PM

    I have a form collecting general user information and uploading a file. I have a php program to insert the general information into our mysql database. How do I insert the file into my database? I can only insert the file's title. 

     

    Also, I saw post  about using FTP regarding files and clicked that option which made my form secure.  How do I remove the security?

     

    Thank you for your help.

  • Profile Image
    EltonCris
    Answered on February 21, 2014 at 01:48 AM

    Hi,

    The POST DATA does not pass the actual file, it only provides the file name and then construct your PHP script to create the file URL. The FTP upload will be of help as well.

    Example:

    <?php

    $submissionid = $_POST['submission_id'];

    $filename= $_POST['uploadFormatted'];

    echo 'http://www.yoursite.com/files/'.$filename;

    ?>

    ----------------

    Just replace https://secure with http://form on the form URL if you do not want to use the secure version of the form.

    Let us know should you have further questions.

    Regards!

  • Profile Image
    NeilVicente
    Answered on February 21, 2014 at 03:10 AM

    @milibra

    As far as I know, databases can only store string-based data, such as an uploaded file's URL, not the actual file itself.

    In addition to my colleague's solution, you may add your PHP script as a Webhook instead of as a Thank You URL in order to capture the (JotForm-hosted) uploaded file's URL.

    If you want to have download the file to your server, you may use PHP's ftp_get function.