I need to merge jQuery File Upload with existing form on all PHP site

114 views
Skip to first unread message

Julie Frey

unread,
Apr 12, 2016, 12:43:15 PM4/12/16
to jQuery-File-Upload
Introduction
My very first web debugging job was handed to me in January. Two or more other developers created the site, much of it partly done or with mistakes. I am not in contact with any of them. (One problem with freelance contract work.) I am an experienced programmer since 1980 (C, Basic, VBA mainly). I learned PHP and JS by reading online to complete each bug fix. I also own and run websites, but nothing this massive. I include many details because I really don't know which is important and my experience so far is that any solution may affect other parts. Plus there are limits given what I have to work with.

Goal: Merge Forms So They Don't Conflict
Today my task is to complete a Post Form on the Admin panel. It's a back office function. The post form consists of a list of clients (with Chosen plugin for multi-select) to receive the post, the post category and post contents. The form is processed with postcontroller.php.

jQuery File Upload was added after post by itself was shown to work including posting to multiple clients (my work).

The Process
The media files upload to the server directory upon submit. After Post Form fields are entered and submitted, postcontroller.php creates the Admin (user) post row which generates the POST ID. Using the POST ID the files are renamed with post_[id]_filename and moved to the uploads folder where all media files are stored (as recommended by a previous developer). Then each selected client gets a copy of the post row with the POST ID. So that when the clients view their profiles, they see a list of media uploads by POST ID. The collection of media files appear in a slider, generated from the post row data. (I did that part. Try to dynamically code a slider for files found in a folder by POST ID. The file renaming bit helped me do the file finding bit later.)

Complication
It's also an assembled site with pieces in different files, a new experience for me and hard to find solutions or examples because most are simple one page HTML sites. The header file is is under tpl as header.php next to form_post.php. They are loaded by post_form.php which loads into index.php.

I Am Nearly There
I have looked up how to merge forms and I get that I need to modify postcontroller.php so that none of the forms conflict when buttons are pressed. (Plus I have the jQuery Form Validation active.)

Current Status
I think I need a custom action for the file uploader form. The current action is the demo action page. How do I call the functions on the PHP page? I added the include at top to access the functions on the post form. I lack experience to know when to keep separate files or put it on the page.

MY CODE
For post form code I have relevant lines. The form is in a table (as given to me) to have two columns so I had to put each jQuery File Uploader piece in cells. (It's harder to keep the styles right with table cells.) As you can see this is an embedded form.

<!-- start id-form -->
<form id="postForm" action="postcontroller.php" method="post" enctype="multipart/form-data">

<!-- The file upload form used as target for the file upload widget -->
<form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data">

<!-- jQuery File Upload button panel - submit button named upload -->
<button type="submit" name="upload" class="start">Start upload</button>
<button type="reset" class="cancel">Cancel upload</button>
<button type="button" class="delete">Delete</button>
<input type="checkbox" class="toggle">

<!-- Post Form button panel - submit button named add -->
<input type="submit" name="add" value="" class="form-submit" />
<input id="restform" class="form-reset">
<a href="post.php" class="form-cancel">Cancel</a>

I have attached the postcontroller.php file. 

Any help anyone can provide would be greatly appreciated.

postcontroller.php
Reply all
Reply to author
Forward
0 new messages