Topic: [0.2.1] xajax.ext.SWFupload *updated*

Good news everyone,

It's time for the next SWFupload version. I fixed a couple of bugs and added some new functions:


changelog:


2008-04-11 vers 0.2.1
    * fixed bug were response wasn't processed in IE

2008-04-10 vers 0.2

    * changed base class to xajaxResponsePlugin
    * added response function to transform forms/fields via xajax
    * added destroy function to unload swf movie and containers
    * added response functions for destroying fields/forms
    * added callback events
    * added config parameter 'multiple'
    * added compressed JS files
    * fixed bug in upload rate
    * fixed bug where xajax request wasn't send when queue was empty
DEMO / docs
Download 0.2.1 (zip)

Re: [0.2.1] xajax.ext.SWFupload *updated*

Hm, everytime I try to upload something, I get the Error Code -200
What could be the reason?

I installed it this way:

index.php
define('XAJAX_DIR', 'xajax/');
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT']);
define('COMMON_DIR', ROOT_DIR.'xajax/common/');

$xajax = new xajax();
require_once (ROOT_DIR.XAJAX_DIR.'xajax_plugins/request/swfupload/swfupload.inc.php');
include_once(COMMON_DIR.'home.common.php');
xajax/common/home.common.php
$xajax->register(XAJAX_FUNCTION, "upload",
    array("mode" => "'SWFupload'", "SWFform" => 'upload_form')
);
$xajax->register(XAJAX_FUNCTION, "transform");
xajax/server/home.server.php
function upload($form) {
    $objResponse = new xajaxResponse();
    $html="";
    foreach ($_FILES as $key => $file) {
        $html .="
            <div style=\"border:1px solid #f0f0f0;background:#fff;padding:4px;margin-bottom:4px;\">
                <div style=\"float:left;width:100px;\">Filename:</div>
                <div style=\"float:left;\">".$_FILES[$key]['name']."</div>
                <br style=\"clear:both;\" />
                <div style=\"float:left;width:100px;\">Size:</div>
                <div style=\"float:left;\">".$_FILES[$key]['size']."</div>
                <br style=\"clear:both;\" />
            </div>
            "    ;
    }
    if ("" == $html) $html="empty queue";
    $objResponse->append("results","innerHTML",$html);

    return $objResponse;
}

function transform() {
    $objResponse = new xajaxResponse();
    $objResponse->clsSwfUpload->transForm('upload_form',
        array(
            "file_types" => "*.jpg;*.gif;*.png;",
            "file_types_description" => "Image Files or mp3",
            "file_size_limit" => "5 MB",
            "upload_complete_handler" => "function () {}",
            "post_params" => array(
                "PHPSESSID" => session_id()
            )                                                                                
        ),
        true
    );

    return $objResponse;
}

It prints the "queue empty" message, if i upload nothing, but as I add a file and upload it, I always get this alert.

Re: [0.2.1] xajax.ext.SWFupload *updated*

Sounds like the flash movie is throwing the error. Which browser / OS did you use?

Re: [0.2.1] xajax.ext.SWFupload *updated*

I'm using FF 2.0.0.13 and WinXP SP2

The full error alert is "Error Code: -200, File name: myfilename.jpg, Message 404"

If I use the script on your website, everything works fine. Do I have to do anything else than copying the plugins folder into my plugins folder?

Re: [0.2.1] xajax.ext.SWFupload *updated*

Please use the full package and replace your old xajax install with the included vers.

Re: [0.2.1] xajax.ext.SWFupload *updated*

Hm, no, still doesn't work. I've replaced the package

Re: [0.2.1] xajax.ext.SWFupload *updated*

k, it seems to be a problem with the flash movie. http://swfupload.org/forum might help, since my plugin is only a kinda wrapper for swfUpload

Re: [0.2.1] xajax.ext.SWFupload *updated*

the only thing I've found is that the upload_url setting should be checked. Where can I find it in the xajax plugin?

Another thing, it works fine with IE7...

Re: [0.2.1] xajax.ext.SWFupload *updated*

The upload_url is set by xajax (REQUEST_URI) right before starting the upload. How does your JS functioncall look like? Are you perhaps able to join us on IRC to discuss the issue? smile

Re: [0.2.1] xajax.ext.SWFupload *updated*

Ok, this issue has been solved:

Flash has sometimes problems sending request to a relative URI. The plugin sets the upload_url for the SWFupload plugin automatically to the defined xajax.config.request_URI or the request URI passed in the xajax.request() call.
Relative URIs seem to work in IE only, but not in FireFox. Changing it to an absolut path (for instance $xajax = new xajax("/my_script.php"); solves the issue. smile

Re: [0.2.1] xajax.ext.SWFupload *updated*

Again, another update. Fixed response processing in IE. Thanks to DaveDamage for reporting the issue. Links and docs are updated.

12 (edited by Photoshop 2008-04-23 10:27:21 AM)

Re: [0.2.1] xajax.ext.SWFupload *updated*

I have
typeerror: args.data.config has no properties
Popup message in Firefox (transform function is not rebuild upload form)

In IE all works fine.

How can i fix it?

All package from xajax.ext.SWFupload_0.2.1.zip

And I have one more big trouble with this package:

In my previous scripts tested on "xajax_0.5_beta_4b_Full.zip" new error added:

RECEIVED [status: 200, size: 134 bytes, time: 93ms]:
<?xml version="1.0" encoding="windows-1251" ?>
<xjx>
<cmd n="as" t="1_button" p="innerHTML"><![CDATA[S(7)]]></cmd>
</xjx>

What is "S" symbol in response? ("(7)" its my data). This error in all my scripts, but in "xajax_0.5_beta_4b_Full.zip" all fine.


Thanks.

Re: [0.2.1] xajax.ext.SWFupload *updated*

I've got an strange issue with SWFUpload (from SWFUpload v2.1.0 Beta 2.zip package). Even included sample swfupload.php file doesn't work - the PHP error is

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in .../xajax/xajax_plugins/request/swfupload/swfupload.inc.php on line 22

The 22 line in the swfupload.inc.php file is:

private $sCallName = "SWFUpload";

Everything looks OK with that line; I haven't edited the file so it is probably the same that in the online demo at http://www.xajaxproject.org/developer/q … pload.php. Can anyone tell me what's the problem I have?

PS PHP, JavaScript, xAJAX are working fine with my setting -- only SWFUpload is the mess.

Re: [0.2.1] xajax.ext.SWFupload *updated*

upgrade to PHP5 smile I do not support PHP 4.x anymore

Re: [0.2.1] xajax.ext.SWFupload *updated*

q_no wrote:

upgrade to PHP5 smile I do not support PHP 4.x anymore

I've discovered that already! ;-) But why? Is there really so many good things to abandon compatibility with older processors? And the error is strange, I still don't understand which difference between 5 and 4.x versions may cause it.

Re: [0.2.1] xajax.ext.SWFupload *updated*

PHP4 runs out of support and yes, PHP5 brings a lot of cool stuff :-)

Re: [0.2.1] xajax.ext.SWFupload *updated*

I need to upload simultaneously (with one click on the "upload" button) files from two queues - like in the http://www.xajaxproject.org/developer/q … upload.php example, but also I require that both file queues had separate settings -- viz., one should select exactly one file, and other may contain more files. But if I configure the whole form via clsSwfUpload->transForm function, I'dont have access to settings of each field. If, v.v., I configure every field separately -- with clsSwfUpload->transField function, I don't see a way that the uploader function accessed both of the fields: the configuration of the uploader (e.g. $xajax->register(XAJAX_FUNCTION,"uploader",array("mode" => "'SWFupload'","SWFform" => "'upload_form'"))) considers only the whole form or a _single_ (but not multy) field.

So, is there a way to set up the uploading plugin for my needs -- viz., via one click load files from several fields (queues) with individual settings?

Re: [0.2.1] xajax.ext.SWFupload *updated*

Hi,

yes, that it is possible...you can for instance create a JS function that triggers both upload functions at once.

Re: [0.2.1] xajax.ext.SWFupload *updated*

I still have question: how can I detect the moment when _all_ uploads complete? The upload_complete_handler starts after every file gets uploaded, and if I want to, say, automatically navigate to another page when all files loaded, what should I do? Thanks a lot for your assistance.

Re: [0.2.1] xajax.ext.SWFupload *updated*

There's no "queue complete" event atm, I'm working on it for the next vers which works completely different (internal), but the queue event will only fire either per form or per field. Perhaps another future version will be able to upload different queues at once and fire one event in the end, but sorry... not atm

21 (edited by batch2k 2008-05-06 2:20:19 PM)

Re: [0.2.1] xajax.ext.SWFupload *updated*

q_no wrote:

There's no "queue complete" event atm, I'm working on it for the next vers which works completely different (internal), but the queue event will only fire either per form or per field. Perhaps another future version will be able to upload different queues at once and fire one event in the end, but sorry... not atm

Here, I don't require such event for separate queries -- I launch the second queue (with multiple files) upon the first one (with one file exactly) finished. But what about the second one -- or, more generally, any queue of unknown length? Maybe there are some tricks with oFile object from the original swfUpload plugin -- such as retrieval of the queue length?..

Or maybe there's a way to access the Stats Object via $objResponse->clsSwfUpload collections? The files_queued parameter contains query length, but I don't know how to receive it.

Actually, by editing the swfupload.xajax_uncompressed.js file I managed to access the files_queued parameter -- from the inside of the xjxSWFup.tools._addQueuedFile function that has swf (swfUpload) object among the parameters:

swf.getStats().files_queued

But now I don't know how to pass this to (or acquire from) php code (or another xajax part). Any ideas?

Re: [0.2.1] xajax.ext.SWFupload *updated*

OK I finally found a way to get the number I need -- the length of the given queue. I have discovered that required JS construction is
xajax.ext.SWFupload.instances['Form or field name'].getStats().files_queued

Re: [0.2.1] xajax.ext.SWFupload *updated*

Please, I need help one more time.
As I said, I want navigate to another page as soon the last file from the queue is uploaded on the server, and I can pass the queue length to the uploader function by the onclick() evaluating of the "xajax.ext.SWFupload.instances['Form or field name'].getStats().files_queued" property.
But I encounter another problem -- I cannot construct the counter inside the uploader function to compare its value with the queue length and determine when to stop.
Whatever I do -- register this counter as a global variable, store it in the $_SESSION array or use the 'static' directive -- the counter initialize from the zero every time when uploader function executes. So I still cannot quit from it and continue with my tasks automatically, because I cannot determine how many times this function had started.
Can you help me, please?

Re: [0.2.1] xajax.ext.SWFupload *updated*

I have a very very dummy question.
I can't understand how the upload mechanism works... when I use the demo of the plugin I see the files are "safely stored in /dev/null" and that's ok, but... how do I change it? Where can I choose the destination directory for  my uploaded files?

Thanks for your patience... wink

L;)

Re: [0.2.1] xajax.ext.SWFupload *updated*

The demo message is just a joke. It doesn't care about the uploaded files, that's all. The files are stored in $_FILES. Look here how to move the files: php.net