I use Uploadify as part of the form. Let me give you some background, this may help. I have a form where the user can add “projects” to the website. First they enter the project name and description. In the view, this updates the PHP / MySQL database table named "project" and gets the identifier.
The user can then upload files to a location on the server. I want to add the project name at the beginning of the file name for the download AND the project ID (which I need to add to the database) before the download starts, and then when the download is complete, add the file data to the database table "image" - associated with " project "through the project identifier.
I know that I bounced back and forth a bit, I need to know how to do this. Two database tables for updating, one for submit and one for uploading files. I need to pass the project name and ID to upload the upload script.
DECISION:
I had to use the uploadify method below to send the project ID to the uploadid script, pre-populating the variable with the pidresult mysql_insert_id:
'onSelectOnce': function(event,data) {
$('#file_upload').uploadifySettings('scriptData', {'pid': pid});
}
Then I could get the pid variable in the PHP uploadify script using a simple entry:
$pid = $_POST['pid'];
Then it was necessary to make a choice inside this script to get the data I needed for the database (the project alias) and add it to the file name before downloading:
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/' . $alias . '-';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
Hope this helps people in the future.
source
share