这是我作为闪光灯所经历过的最奇怪的事情。 php程序员说我的代码没有传递任何变量(变量Name和email)。这是as3。 我把PHP放了,但程序员告诉我php与它无关,我没有解决上传文件,地址是正确的(当我输入时)
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 = "some@someEmail.com";
//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")
}
任何帮助都会受到赞赏,因为我已经在代码中更改了一些小东西,现在仍然没有进展
答案 0 :(得分:2)
您在致电负载之前忘记了一行代码:
urlreq.data = urlvars;
您需要将变量分配给请求。