How can I update $uploader->UploadUrl="../php/cmds/PHPFileUploadCmd.php" after Page Load then after ajax resulthandler?

Last post 03-05-2012, 8:50 PM by manpakhong. 2 replies.
Sort Posts: Previous Next
  •  03-02-2012, 3:57 AM 73281

    How can I update $uploader->UploadUrl="../php/cmds/PHPFileUploadCmd.php" after Page Load then after ajax resulthandler?

    Dear Expert,
     
    the code:
            <?php
                $uploader=new PhpUploader();
                   $uploader->Name="myuploader";
                $uploader->MultipleFilesUpload=true;
                $uploader->InsertButtonID="uploadBtn";    
                $uploader->InsertText="Select multiple files (Max 10M)";
                $uploader->MaxSizeKB=10240;
                $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif,*.bmp";
                $uploader->SaveDirectory="../pics/";
                $uploader->UploadUrl="../php/cmds/PhpFileUploadCmd.php";
                $uploader->FlashUploadMode="Partial";
                $uploader->Render();
            ?>
     will generate :
    <img id="myuploader_Loader_unique" contextvalue="9225222354c53c10fd7b2d3307b16a82" onerror="this.onload()" onload="this.style.display="none" ; CuteWebUI_AjaxUploader_Initialize(this.id);" borderstyle="border-style:solid;border-width:1px;border-style:#444444;" barstyle="Continuous" infostyle="padding-left:3px;font:normal 12px Tahoma;" barheight="20" panelwidth="360" numfilesshowcancelall="2" showprogressinfo="1" showprogressbar="1" multiplefilesupload="1" uploadtype="Auto" uploadcursor="Auto" uploadingmsg="Uploading.." cancelallmsg="Cancel all Uploads" canceluploadmsg="Cancel upload" maxsizekb="10240" maxhttpsizekb="204800" maxpartialsizekb="102400" flashloadmode="1" extensions="*.jpg,*.png,*.gif,*.bmp" insertbuttonid="uploadBtn" uploadurl="../php/cmds/PhpFileUploadCmd.php" resourcehandler="/albums/php/phpFileUploader/phpuploader/ajaxuploaderresource.php" resourcedirectory="/albums/php/phpFileUploader/phpuploader/resources" src="http://cutesoft.net/albums/php/phpFileUploader/phpuploader/ajaxuploaderresource.php?type=file&file=continuous.gif" serverlang="PHP" uploadmodulenotinstall="1" namespace="CuteWebUI" uniqueid="myuploader" style="display: none;"> 
     for the page first load.
     
    The  uploadurl="../php/cmds/PhpFileUploadCmd.php" will be preset into the <img  id="myuploader_Loader_unique"
    ></img> tag.
     
    However I have an ajax call  to insert something into mysql first and then the ajax result handler will return a new sid to me. e.g. 
    albumSid = '3'. 
    I need to put the albumSid = '3' into  uploadurl="../php/cmds/PhpFileUploadCmd.php" + "?albumSid=3" into it.
     
    How can I change it?
     
    Regards
     
    Man Pak Hong
    manpakhong@hotmail.com
     
     
     
     

    Man Pak Hong, Dave
  •  03-05-2012, 8:34 PM 73342 in reply to 73281

    Re: How can I update $uploader->UploadUrl="../php/cmds/PHPFileUploadCmd.php" after Page Load then after ajax resulthandler?

    I solved it by myself eventually.
     
    Just at the resultHandler after Ajax post. change it with JQuery. The javascript id of the phpFileUploader button is "myuploader_Loader_unique". So that I can change it with simple JQuery script as follows:
     
    function insertAlbumResultHandler(res){

        //alert(res);
        var obj = JSON.parse(res);
        if (obj.albums[0].sid > 0)
        {
            $('#myuploader_Loader_unique').attr("uploadurl", "../php/cmds/PhpFileUploadCmd.php?albumSid=" + obj.albums[0].sid);
            $('#publishBtn').removeAttr("disabled");
            
            $("#albumTable .sid").val(obj.albums[0].sid);
            //uploadurl += "?albumSid=" + obj.albums[0].sid;
              disableAlbumControls(false);
              $('#submitAlbumBtn').fadeOut(3000, function(){
                  $(".submitAlbumTr").css("display", "none");
                  $('#submitAlbumBtn').css("display", "none");
              });
            $('#uploadBtn').fadeIn(3000, function() {
                // Animation complete
            });
        } // end if (obj.album[0].sid > 0)
        else
        {
            alert(res);
        } // end if (obj.album[0].sid > 0) ... else
    } // end showResult 
     
     
    Man Pak Hong, Dave
    manpakhong
    manpakhong@hotmail.com

    Man Pak Hong, Dave
  •  03-05-2012, 8:50 PM 73343 in reply to 73342

    Re: How can I update $uploader->UploadUrl="../php/cmds/PHPFileUploadCmd.php" after Page Load then after ajax resulthandler?

    However, even I can change the attribute of "#myuploader_Loader_unique',  it still post the old url without the query string.
     
    Any place I can change it at runtime that will post the query string "?albumSid=_runtimeVar_"
     
    Experts help!
     
     
    Regards,
    Man Pak Hong, Dave

    Man Pak Hong, Dave
View as RSS news feed in XML