Just to start, yes I've read all the other Stack Overflow questions relating to this topic, but none of them provided me with a solution. One had a promising link that turned about to be dead. Apparently the entire swfupload forum doesn't exist anymore.
My problem is of course relating to passing my session variables to the actual PHP that processes the upload and inserts a line into a MySQL database. Two of the fields in that SQL line are session variables from the logged in user.
Based on the documentation and what I read from other threads, this is my code (or the relevant parts):
This is my javascript code from the main upload page. There is more but this is what's relevant. This code is a part of a $content
variable that I use in a template function so its PHP syntax. Note, when I check this code in the browser it renders the correct values there.
var swfu;
window.onload = function() {
var settings = {
flash_url : "js/swfupload/swfupload.swf",
upload_url: "process_upload.php",
post_params: {
"user_id" : "'.$_SESSION['user_id'].'",
"school_id" : "'.$_SESSION['school_id'].'"
},
file_size_limit : "1000 MB",
file_types : "*.wmv; *.mpg; *.avi; *.vob; *.mov; *.m4v; *.mpeg; *.mkv; *.flv; *.3gp",
file_types_description : "All Files",
file_upload_limit : 10,
Now, in my process_upload.php file if I do this:
$user_id = $_POST['user_id'];
$school_id = $_POST['user_id'];
Then use those variables in a query:
mysql_query("INSERT INTO table SET name='".$file_name."', school_id='".$school_id."', user_id='".$user_id."'") or die(mysql_error());
The query is successful and I get an entry in the database, but it doesn't fill in user_id
and school_id
and my error log shows Undefined Index error on that line.