1

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

1 Answer 1

2

you forgot one line of code right before you call the load:

urlreq.data = urlvars;

You need to assign the vars to the request.

Sign up to request clarification or add additional context in comments.

8 Comments

before call the load? as in before loader.load(urlreq); ?
yes, the vars need to be assigned to the urlreq before you call the load
thanks, I'll test this tomorrow at work and get back with an answer if it worked :)
Don't you mean urlreq.data = urlvars
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.