Reputation: 31
This is the weirdest thing I have ever experienced as a flasher. the php programer says that my code does not pass it any variables (the variables Name and email). Here is the as3. I'd put the php but the programer tells me the php has nothing to do with it, I am not addressing the upload file, the address is correct (when I type it in)
texti.visible = false;
var loader : URLLoader = new URLLoader;
var urlreq:URLRequest = new URLRequest("https://[someadress]/upload.php");
var urlvars:URLVariables = new URLVariables();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlreq.method = URLRequestMethod.POST;
//var urlreq:urlreq = new URLRequest("https://localhost/upload/upload.php");
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
var allTypes:Array = new Array(imageTypes);
var fileRef:FileReference = new FileReference();
fileRef.addEventListener(Event.SELECT, syncVariables);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
btn_browse.addEventListener(MouseEvent.CLICK, browseBox);
btn_upload.addEventListener(MouseEvent.CLICK, uploadVars);
function browseBox(event:MouseEvent):void {
fileRef.browse(allTypes);
}
function uploadVars(event:MouseEvent):void {
urlvars.Name = "somename";
urlvars.Email = "[email protected]";
//urlvars.fb_id = Main.facebook1;
urlvars.picname = fileRef.name;
trace(urlvars.Name);
trace(urlvars.Email);
loader.load(urlreq);
fileRef.upload(urlreq);
btn_upload.visible = true;
}
function syncVariables(event:Event):void {
texti.text = "" + fileRef.name;
//blocker.visible = false;
btn_upload.visible = true;
}
function completeHandler(event:Event):void {
trace("h1");
var bytestoLoad:Number = loaderInfo.bytesTotal;
var numberLoaded:Number = loaderInfo.bytesLoaded;
if (bytestoLoad == numberLoaded)
{
gotoAndStop(2);
trace(fileRef.name);
t_status.gotoAndPlay(2);
btn_upload.removeEventListener(MouseEvent.CLICK, uploadVars);
btn_browse.removeEventListener(MouseEvent.CLICK, browseBox);
}
else
{
trace("wtf?");
}
}
function progressHandler(event:ProgressEvent):void {
trace("inprogress")
}
any help would be appreciated as I have been changing minor stuff in the code for hours now and still no progress
Upvotes: 1
Views: 224
Reputation: 1189
you forgot one line of code right before you call the load:
urlreq.data = urlvars;
You need to assign the vars to the request.
Upvotes: 2