Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Submit a form with an attachment to database using Ajax, PHP and MySQL.

I have a simple form with a file attachment, textarea, and select elements. I wanna upload it using PHP, MySQL and Ajax to the database. Please help.

          <form class="urp_form" action="urp.php" method="post" enctype="multipart/form-data">
            <input type="text" id="author" value="" name="author" placeholder="Enter the name of the author">
            <textarea name="excerpt" placeholder="Brief description about what you are trying to upload ... "></textarea>
            <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
            <input type="file" name="filename" value="" id="filename">
            <select name="sector" id="sector" class="select2">
              <option value="sector" selected>Choose the sector</option>
              <option value="1">Education</option>
              <option value="1">Sports</option>
            </select>
          </form>