1 (edited by tirso 2009-01-28 3:08:28 AM)

Topic: swfupload doesn't work on a webserver

Hi to all


I have successfully done uploading images using swfupload, it works perfectly on my localhost but when I already uploaded in a webserver it doesn't work anymore. Even the sample of q_no still doesn't work. But, I am just wondering why in other pc even in live was works perfectly. I am not sure if the problem is adobe flash player because as I said it works in my localhost. It's very hard for me to trace the errors because I could browse the image and once I hit the upload button the "status bar" and fade will works. but the images was not copy. I putted an alert message in  uploader function to check if it is works but, no alert message was appeared. Furtheremore, I tried to hit the upload button without interfering the browse button and the alert message was works.

thanks in advance

Tirso

link in live    http://www.tirso.webberzsoft.com/myswfupload.php

<?

    if (isset($_POST['PHPSESSID'])) {

        session_id($_POST['PHPSESSID']);

    }

    session_start();



    ini_set("display_errors",1);

    error_reporting(E_ALL ^E_NOTICE);

   

    if (!isset($_SESSION['foo'])) $_SESSION['foo'] = 0;

   

    $core = './xajax_core';

    require_once $core . '/xajax.inc.php';

   

    $xajax = new xajax();

    require_once './xajax_plugins/request/swfupload/swfupload.inc.php';

    $xajax->configure("javascript URI","");

   

    $xajax->register(XAJAX_FUNCTION,"uploader",array("mode" => "'SWFupload'","SWFform" => "'upload_form'"));

    $xajax->register(XAJAX_FUNCTION,"transform");

    $xajax->register(XAJAX_FUNCTION,"destroyform");

   

    $_SESSION['foo']++;

    $xajax->processRequest();

   

    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;

    }

   

    function destroyform() {

   

        $objResponse = new xajaxResponse();

        $objResponse->clsSwfUpload->destroyForm('upload_form');

   

        return $objResponse;

    }



    function uploader($aFormValues) {

        $objResponse = new xajaxResponse();

        $objResponse->Alert("check");
       
        $html="";

        foreach ($_FILES as $key => $file) {

            $realpath = "picturemember/images/".$_FILES[$key]['name'];
           
            move_uploaded_file($_FILES['upFile_standard']['tmp_name'], $realpath);
        }

        return $objResponse;

    }

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php $xajax->printJavaScript();?>

    <style type="text/css">

        /* <![CDATA[ */

       

.swf_queued_file {

    background:#f0f0f0;

    margin-bottom:2px;

    border:1px solid #c0c0c0;

    padding:4px;

    clear:both;

}



.swf_queued_file_removed {

    background:#FFDFDF;

    margin-bottom:2px;

    border:1px solid #c0c0c0;

    padding:4px;

    clear:both;

}



.swf_queued_file_finished {

    background:#DFFFE6;

    margin-bottom:2px;

    border:1px solid #c0c0c0;

    padding:4px;

    clear:both;

}





.swf_queued_file_remove {

    font-size:11px;

    float:left;

    width:20px;

    height:20px;

    background:url(img/bin_closed.png) no-repeat top left;   

    overflow:hidden;

}

.swf_queued_filename{

    font-size:11px;

    display:inline;

    float:left;

    width:180px;

    overflow:hidden;

}



.swf_queued_file_progress_container {

    float:left;

    display:inline;

    background:#d0d0d0;

    margin-top:4px;

    height:10px;

    width:220px;

    margin-right:8px;

}

.swf_queued_file_progress_bar {

    height:8px;

    background:#333;   

    width:1px;

}



.swf_queued_filesize{

    font-size:11px;

    float:left;

    overflow:hidden;

}

         /* ]]> */

    </style>
   
</head>

<body onload="xajax_transform();">
<form enctype="multipart/form-data" id="upload_form" action="upload.php" onsubmit="return false;" method="post" >
<input type="file" id="upFile_standard" name="upFile_standard" value=""/>
<input id="uploadBtn" type="button" onclick="xajax_uploader(xajax.getFormValues('upload_form'));" value="upload file"/>
</form>
</body>
</html>

Re: swfupload doesn't work on a webserver

Hi tirso, just tried the link - it works now, does it?

Re: swfupload doesn't work on a webserver

Hi dickdock

thanks for your immediate replied, yes I saw your image uploaded, but in my pc there is no images was being uploaded, though there is nothing any errors appeared. even the alert message doesn't showed. I don't understand that kind of behavior. I am guessing that is because of flash player but in my localhost at the same code I can upload image. How could I trace this kind of behavior?

thanks a lot dickdock.

Best regards

tirso

Re: swfupload doesn't work on a webserver

Hi tirso, the $objResponse->Alert("check") came up for me.

Probably not the problem but this code in the foreach ($_FILES as $key => $file) loop looks wrong:

move_uploaded_file($_FILES['upFile_standard']['tmp_name'], $realpath);

Should that be move_uploaded_file($_FILES[$key]['tmp_name'], $realpath) ?

Anyway if you put in an error_log("_FILES=" . print_r($_FILES, true)) to see what you're getting it should help.

Re: swfupload doesn't work on a webserver

Just remembered that you also need to check that upload_tmp_dir in php.ini is writable on your server (http://ie.php.net/manual/en/ini.core.ph … ad-tmp-dir).

Re: swfupload doesn't work on a webserver

hi dickdock

I have already changed move_uploaded_file($_FILES[$key]['tmp_name'], $realpath) and upload_tmp_dir also writable  but still doesn't work. by checking this I had created a two php pages to test if does really have no problem with regards the permission of the said "upload_tmp_dir" directory and I was successfully uploaded several images. The thing I was wondering is once I hit the button "browse files" then select image through  upload button, the test (alert message was not appear) so meaning that the uploader function doesn't call of xajax. But if I directly hit the upload button without interfering "browse files" (alert message was showed).

thanks for your patient for helping me to solve this problem.

Best regards

tirso

Re: swfupload doesn't work on a webserver

Hi tirso, I just tried the link you gave http://www.tirso.webberzsoft.com/myswfupload.php and it appeared to work for me again. I hit the "Browse Files" button, selected an image, its name appeared with the progress bar below the buttons, then hit "Upload" and after a delay the progress bar completes and the "check" alert appears. Tried it again just now with a jpg ~2.3M and it appeared to work again (thought it might be MAX_FILE_SIZE or upload_max_filesize) so I don't know what to say. Maybe remove the alert from your response handling and just use error_log()s instead to see if you can trace what's happening.

Re: swfupload doesn't work on a webserver

hi dickdock

I couldn't say how to thank you for your patient for me. Maybe there is a problem on my pc because I tried in another pc and it also works fine. I already replace alert with error_log("_FILES=" . print_r($_FILES, true)); but nothing will appeared on my browser. Name and the progress bar will appear below the button after selecting images, is the running progress bar and fading out  will run by the uploader function? because I could not trace it by my self. 

thank you so much dickdock

Best regards

tirso

Re: swfupload doesn't work on a webserver

Tirso, what version of flash are u using? If you are using Flash10 you need an updated version of the SWFupload plugin. I'm going to release the next beta with flash10 support this week.

Re: swfupload doesn't work on a webserver

hi q_no

I am using version 9. Good to hear you that version10 will release this week

thank you so much.


Best Regards

Tirso