سؤال

I have a simple swf file upload script that uploads a file as soon as user selects it. It works fine however I'm trying to pass the saved filename from the php script (simple echo "file_name.txt";) back to the swf so it can pass it back to the form via javascript.

Here's a simple snippet of the AS2 code, can someone who has some experience with the FileReference component help me out with a solution to get the output from the php script?

var file_fr:FileReference = new FileReference();
var list_obj:Object = new Object();
list_obj.onComplete = function() {
    // need to get response text from script.php
}
file_fr.addListener(list_obj);

if (!file_fr.upload("/path/to/script.php")) {
    feedback.text = "error";
}
هل كانت مفيدة؟

المحلول

I believe FileReference.upload isn't going to be made smart enough to return anything other than success fail codes. So what you need to do is pass a UID on the end of your URL and then use that to query php on what it did on its end in another call.

Rereading your post, do you want the local file or the remote file name? Local should be available in the FileReference.

Here is old code I dug up -

Note: This is AS3. And it deals with 3 images, so...

AS3 FileReference Example

And then the PHP

PHP AS3 FileReference Example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top