I’m creating an upload app where you select several FLVs, fill in some general information about them and upload them.
The videos are uploading fine. My problem is transferring over the data that they filled out to the upload script to insert into the database.
Here is my function that starts the upload.
function startUpload(e:Event):void {
var params:URLVariables = new URLVariables();
//location variables to be sent
params.cid = cid;
params.sid = sid;
params.tid = tid;
//data variables to be sent
params.title = title;
params.description = description;
params.segtitle = segtitle;
params.location = location;
params.date = date;
params.rights = rights;
params.keywords = keywords;
var request:URLRequest = new URLRequest("upload.php");
request.method = URLRequestMethod.POST;
request.data = params;
var list:Number = filelist.length;
var uploadWhat = fileAr[currentIndex];
try {
uploadWhat.upload(request);
uploadWhat.addEventListener(ProgressEvent.PROGRESS, progressHandler);
uploadWhat.addEventListener(Event.COMPLETE, completeHandler);
status.text = "Uploading " + (currentIndex + 1) + " of " + list;
} catch (error:Error) {
status.text = "Unable to upload";
}
}
and my php:
<?php
include 'connect.php';
//location vars
$cid = $_POST['cid'];
$sid = $_POST['sid'];
$tid = $_POST['tid'];
//data vars
$title = $_POST['title'];
$description = $_POST['description'];
$segtitle = $_POST['segtitle'];
$location = $_POST['location'];
$date = $_POST['date'];
$rights = $_POST['right'];
$keywords = $_POST['keywords'];
/***************************************************
* upload file.
***************************************************/
$addTime = mktime();
$l_sFileName = strtolower( str_replace( " ", "_", basename( $_FILES['Filedata']['name'] ) ) );
$l_sFilePath = "videos/".$addTime.$l_sFileName;
move_uploaded_file( $_FILES['Filedata']['tmp_name'], $l_sFilePath );
$sql = mysql_query("INSERT INTO video (tape_id,filename,name,thumbnail,description,seg_title,location,date,rights,keywords) VALUES ('$tid','$l_sFilePath','$title','','$description','$segtitle','$location','$date','$rights','$keywords'");
?>
I have a feeling its not like AS2, where you would just do
data.title = titlefield.text
and then sendAndLoad…thats the way I know how to do it in AS2, but this being AS3, I’m sure im in the wrong on this one.
Any ideas?