简体   繁体   English

将文件从Flash上​​传到服务器PHP

[英]Upload file from flash to server PHP

I'm going to upload files from flash to server. 我将文件从闪存上传到服务器。 When user begin, input his username , then I send it to php, this way: 当用户开始时,输入他的用户名 ,然后我将其发送给php,方法如下:

    var myusername:String = username.text;
    username.restrict = "A-Za-z0-9";
    login_btn.addEventListener(MouseEvent.CLICK,login);
    function login (evt:MouseEvent):void{

    var loader : URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("http://domain/uploads/upload.php");
    request.method = URLRequestMethod.POST;
    var variables:URLVariables = new URLVariables();
    var userid:String = myusername;
    variables.ID = userid;
    request.data = variables;
    loader.load(request);
}

upload.php : upload.php:

<?php
$myuser = $_POST['ID'];
$uploads_dir = './uploads/'.$myuser;

if( $_FILES['Filedata']['error'] == 0 ){
    if( move_uploaded_file( $_FILES['Filedata']['tmp_name'],
         $uploads_dir.$_FILES['Filedata']['name'] ) ){
        exit();
    }
}
echo 'error';
exit();
?>

The problem is that files upload to uploads folder not in user folder. 问题是文件上载到不在用户文件夹中的上载文件夹中。 Anyone could help me please? 有人可以帮我吗?

What is the value of $_POST['ID'] ? $_POST['ID']的值是多少?

I don't see you setting that anywhere in the request. 我看不到您在请求中的任何位置进行设置。 There's this: 有这个:

variables.UID = userid;

But wouldn't that be $_POST['UID'] and not $_POST['ID'] ? 但这不是$_POST['UID']而不是$_POST['ID']吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM