Skip to content

How to use the filemanager from a simple textfield

Pavel Solomienko edited this page Feb 10, 2016 · 1 revision

How to use the Filemanager from a simple textfield ?

Simply include the following javascript code into HEAD tag

     <script type="text/javascript">
      // File Picker modification for FCK Editor v2.0 - www.fckeditor.net
     // by: Pete Forde <pete@unspace.ca> @ Unspace Interactive
     var urlobj;

     function BrowseServer(obj)
     {
          urlobj = obj;
          OpenServerBrowser(
          'index.html',
          screen.width * 0.7,
          screen.height * 0.7 ) ;
     }

     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, "BrowseWindow", sOptions ) ;
     }

     function SetUrl( url, width, height, alt )
     {
          document.getElementById(urlobj).value = url ;
          oWindow = null;
     }
     </script>

And the HTML part :

    <button type="button" onclick="BrowseServer('id_of_the_target_input');">Pick Image</button>
    <input type="text" id="id_of_the_target_input"/>

That's folk!

(thank you Dobled, for sharing your tip!)