$ _SERVER [" HTTP_REFERER"];当访问vai`swf`电影时,在Firefox上为null

时间:2014-08-25 14:59:00

标签: php actionscript-3 flash firefox

我尝试使用flash上传文件

我已关注action-script中的代码:

var fileRef:FileReferenceList = new FileReferenceList();
fileRef = new FileReferenceList();
fileRef.browse(new Array( new FileFilter( "Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png" )));
fileRef.addEventListener(Event.SELECT, fileSelectHandler);

var uploadURL:URLRequest = new URLRequest();
var uploadPhotoScript:String = "http://localhost/uploader/upload.php";
uploadURL.url = uploadPhotoScript;

function fileSelectHandler(event:Event):void {
    for each(var fileToUpload:FileReference in fileRef.fileList){
            uploadSingleFile(fileToUpload);
        }
}

function uploadSingleFile(file:FileReference):void {
file.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
file.upload(uploadURL);
file.addEventListener(Event.COMPLETE, completeHandler);
}

function onUploadProgress(e:ProgressEvent):void
{
    var f:FileReference = e.currentTarget as FileReference;
    var fileName:String = f.name; //Now I know which file it is, I can update accordingly
    var progress:Number = (e.bytesLoaded / e.bytesTotal) * 100; //shows percent, you might want to round this off using Math.round(number);
}

function completeHandler(event:Event):void {
    trace("upload complete");
}

upload.php的:

<?php
if(isset($_SERVER["HTTP_REFERER"]){
  $ref=$_SERVER["HTTP_REFERER"];
  $ref=explode($ref,"/");
  $ref=$ref[2];
   if($ref=="localhost"){
     if(!empty($_FILES)){
        $tmpfile = $_FILES['Filedata']['tmp_name'];
        $targetfile = dirname(__FILE__) . '/' . $_FILES['Filedata']['name'];
       move_uploaded_file($tmpfile, $targetfile);
     }
  }
else{
header("location:NotLocalhost.html");
exit;
}
}
else{
header("Location:NOREF.html");
exit;
}
?>

此代码适用于除Firefox之外的所有浏览器。 coz在firefox中$_SERVER["HTTP_REFRER"]变为空,并显示NOREF.html

另外在firefox中,当另一个htmlphp脚本访问该脚本时,工作正常,但是当访问vai swf电影时,该电影依次为<embeded> in html页面。然后REFERER变为空。

有什么想法吗?我该如何解决这个问题?

0 个答案:

没有答案