We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    I need to have an image uploader, and file browser in a module -- so I’ve ripped the relevant code from a template variable for the image file/browser.

    Although I can do uploads, and the the file browser opens and I can also see images.

    However I can never seem to pick an image, it never calls back or returns the image to the file picker.

    Can someone point out what I’m doing wrong?

    <script type="text/javascript">
    	var lastImageCtrl;
    	var lastFileCtrl;
    	function OpenServerBrowser(url, width, height ) {
    		var iLeft = (screen.width - width) / 2 ;
    		var iTop = (screen.height - height) / 2 ;
    
    		var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes' ;
    		sOptions += ',width=' + width ;
    		sOptions += ',height=' + height ;
    		sOptions += ',left=' + iLeft ;
    		sOptions += ',top=' + iTop ;
    
    		var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
    	}
    	function BrowseServer(ctrl) {
    		lastImageCtrl = ctrl;
    		var w = screen.width * 0.7;
    		var h = screen.height * 0.7;
    		OpenServerBrowser('/manager/media/browser/mcpuk/browser.html?Type=images&Connector=/manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=/', w, h);
    	}
    
    	function BrowseFileServer(ctrl) {
    		lastFileCtrl = ctrl;
    		var w = screen.width * 0.7;
    		var h = screen.height * 0.7;
    		OpenServerBrowser('/manager/media/browser/mcpuk/browser.html?Type=files&Connector=/manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=/', w, h);
    	}
    
    	function SetUrl(url, width, height, alt){
    		if(lastFileCtrl) {
    		var c = document.mutate[lastFileCtrl];
    		if(c) c.value = url;
    		lastFileCtrl = '';
    		} else if(lastImageCtrl) {
    		var c = document.mutate[lastImageCtrl];
    		if(c) c.value = url;
    		lastImageCtrl = '';
    		} else {
    		return;
    		}
    	}
    </script>
    <input id="logo_image" type="text" onchange="documentDirty=true;" style="width: 300px;" value="" name="logo_image"/>
    <input type="button" onclick="BrowseServer('logo_image')" value="Insert" />
    
      • 27744
      • 2 Posts
      var c = document.mutate[lastFileCtrl];
      replace with
      var c = document.getElementById(lastFileCtrl);