【问题标题】:Submitting files in webform using POST on Drupal (AS3)在 Drupal (AS3) 上使用 POST 在 webform 中提交文件
【发布时间】:2014-10-23 05:00:40
【问题描述】:

我有这张图片,我已经将它转换为 BitmapData。我的 localhost drupal 网站上有一个网络表单。在网络表单中,我有一个文件字段和一些其他文本字段。现在的问题是我使用了一个简单的URLVariable 来提交我的所有文本字段,如下所示:

var requestVars:URLVariables = new URLVariables();
requestVars['submission[data][1][values][0]']= values.text;

但我不知道提交文件的语法。请帮忙!

【问题讨论】:

    标签: actionscript-3 drupal-7 drupal-webform


    【解决方案1】:

    要使用 AS3 上传文件,您可以使用 FileReference.upload

    在这里查看示例:FileReference example (Adobe)

    编辑:

    在 adobe 的最后一个例子中,我们有这个:

    var file:FileReference = FileReference(event.target); file.upload(uploadURL);

    所以我们的闪存会将文件发送到uploadURL,在我们的示例中,这是一个ColdFusion脚本(.cfm)。

    例如,使用 php 来做到这一点,请看这里:http://php.net/manual/en/features.file-upload.post-method.php

    在服务器端使用 php 的示例:

    AS3 代码

    ...
    var uploadURL = 'http://your-site/your-php-script.php';
    ...
    var file:FileReference = FileReference(event.target);
    file.upload(uploadURL);
    

    PHP 代码 (your-php-script.php) :

    <?php
    
        // set uploads dir
        $uploads_dir = '/uploads_dir';
    
        if (!empty($_FILES)) {
    
            $temp_file = $_FILES['Filedata']['tmp_name'];
            $target_path = $_SERVER['DOCUMENT_ROOT'] . $uploads_dir;
            $target_file = rtrim($target_path,'/') . '/' . $_FILES['Filedata']['name'];
    
            // move uploaded file from temp dir to target dir
            move_uploaded_file($temp_file, $target_file);
        }
    
    ?>
    

    【讨论】:

    • 我已经调查过了,但是我应该将文件上传到哪里> 通过网络表单提交上传文件后,文件会保存在哪里?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    相关资源
    最近更新 更多