Menu

Storing Uploaded File in MySQL Database

Help
Xangis
2006-10-25
2013-06-03
  • Xangis

    Xangis - 2006-10-25

    Would it be possible to store the uploaded file into the record that the form adds to the MySQL database?  In fact, when I set up my database I created the file field as a MEDIUMBLOB object assuming that the form would automatically store the uploaded file in the database field if the field was filled in during form generation.

    What sort of modification would I have to make to be able to store the uploaded file into the MySQL database record?  Is it something in a form that could just be put right in or would additional processing be necessary?  I'm far from expert on PHP (expert with C++, moderately skilled Python, SQL, and HTML, PHP uber-noob), but I could probably figure out what to do if pointed in the right direction.

    Has anyone attempted to do this before?

    I'd also like to be able to attach the file to the email that is sent.  Has anyone done this successfully?  It's trivial enough in Python, but I have no idea whether creating a multipart email would be a challenge in PHP.

    In my most ideal situation, the script would put the uploaded file into the database, attach it to the email, and not actually store it on the server.

    Thank you,
    Jason Champion

     
    • Musawir Ali

      Musawir Ali - 2006-10-25

      unfortunately it is not simple enough to be handled with a small modification. but I have been thinking about uploaded file management, and maybe in the next version of phpFormGenerator I'll just have them stored in mysql rather than on disk. Although, sending email with the file as an attachment is probably not something that I would want to incorporate because it opens up lots of spamming possibilities.

       
    • Xangis

      Xangis - 2006-10-26

      I see how an email attachment could be a problem, especially where viruses and spam are concerned.  However, storing files in MySQL would be most excellent because I would be able to do a lot with them and they would not be publicly available unless I wanted them to be.

      I'm using a generated form for writers to submit stories in .RTF, .DOC, and .TXT format to be considered for a magazine of science fiction and fantasy stories (All Possible Worlds: http://www.allpossibleworlds.net\), so having the documents readily accessible to anyone on the 'net could be a problem.

      I've made a small donation to this project in the hope that you'll be more likely to include database storage in the next release. :)

      Thank you,
      Jason Champion

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.