how can i return newly updated file name to CuteWebUI_AjaxUploader_OnTaskComplete(task)?

  •  02-12-2012, 2:51 AM

    how can i return newly updated file name to CuteWebUI_AjaxUploader_OnTaskComplete(task)?

    front end code:
        <?php
            $uploader=new PhpUploader();

            $uploader->MultipleFilesUpload=true;
            $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();
        ?>

    <script type='text/javascript'>
        function CuteWebUI_AjaxUploader_OnTaskComplete(task)
        {
            var div=document.createElement("div");
            var table=document.createElement("table");


            var tableRow=document.createElement("tr");
            var tableData=document.createElement("td");
            var tableData1=document.createElement("td");

            var input=document.createElement("input");
            input.setAttribute("type","text");
            input.setAttribute("name", "albumPicComment");

            var link=document.createElement("a");
            link.setAttribute("href","../pics/"+task.FileName);
            link.innerHTML="You have uploaded file : ../pics/"+task.FileName;
            link.target="_blank";
            
            var img=document.createElement("img");
            img.setAttribute("src", "../pics/" + task.FileName);
            img.setAttribute("class", "postBackPics");

            div.appendChild(table);
            table.appendChild(tableRow);
            tableRow.appendChild(tableData);
            tableRow.appendChild(tableData1);
            tableData.appendChild(img);
            tableData1.appendChild(input);
            img.appendChild(link);
            document.body.appendChild(div);
        }
        </script>
     
    background code :
     
    <?php

        $currentDir = getcwd();
        $rootDir = 'albums';
        $findRootDirPos = strpos($currentDir, $rootDir, 0);
        $currentDir =  substr_replace($currentDir, '' , $findRootDirPos + strlen($rootDir));
        $currentDir = $currentDir . '/';
        
        require_once $currentDir . "php/phpFileUploader/phpuploader/include_phpuploader.php";
        
        $uploader=new PhpUploader();
        
        $mvcfile=$uploader->GetValidatingFile();
        
        if($mvcfile->FileName=="accord.bmp")
        {
            $uploader->WriteValidationError("My custom error : Invalid file name. ");
            exit(200);
        }
        
        //USER CODE:
        
        $targetfilepath= $currentDir . "pics/pre" . $mvcfile->FileName;
        if( is_file ($targetfilepath) )
            unlink($targetfilepath);
        $mvcfile->MoveTo( $targetfilepath );
        
        $uploader->WriteValidationOK();

    ?>
     
    ================================
    regards,
     
    Man Pak Hong, Dave
    manpakhong@hotmail.com
    manpakhong@yahoo.com
     
    Analyst Programmer
     

    Man Pak Hong, Dave
View Complete Thread