Announcement

Collapse
No announcement yet.

file manager

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • file manager

    Hey guys have been trying to add a file manager to a blank application but keep coming up with errors for some reason, the actual version runs loverly on its own, but when added to a blank app I get errors with unexpected { on various lines.. which kinda makes no sense.

    Trying to use this piece of code: http://sourceforge.net/projects/enco...code-explorer/

    If anybody has got this working or an alternative way of creating a file browser within a blank app, please share. Or of course if u don't mind trying the above script and giving us a solution would also be great

    thx in advance

  • #2
    Originally posted by jamieO View Post
    Hey guys have been trying to add a file manager to a blank application but keep coming up with errors for some reason, the actual version runs loverly on its own, but when added to a blank app I get errors with unexpected { on various lines.. which kinda makes no sense.

    Trying to use this piece of code: http://sourceforge.net/projects/enco...code-explorer/

    If anybody has got this working or an alternative way of creating a file browser within a blank app, please share. Or of course if u don't mind trying the above script and giving us a solution would also be great

    thx in advance
    As I have no reply on this so far I was wondering if anybody else has a script they use within a blank application as a folder/file navigation?
    I have tried to create a basic folder list of files but for some reason its failing all the time with a blank app.....

    ideas? solution?

    Need to navigate within the file folder, list files (names, type, size), download individual or all from folder zipped.

    thx

    Comment


    • #3
      Originally posted by jamieO View Post
      As I have no reply on this so far I was wondering if anybody else has a script they use within a blank application as a folder/file navigation?
      I have tried to create a basic folder list of files but for some reason its failing all the time with a blank app.....

      ideas? solution?

      Need to navigate within the file folder, list files (names, type, size), download individual or all from folder zipped.

      thx
      Can you share your blank to see how is implemented and give a hand?
      /Giuseppe

      Professional Scriptcase Services
      Some Customers opinions

      Comment


      • #4
        Hi Giu

        have managed to list the files within the folder but now am having issues with the zip creation and close button, any help would be great bud! thanks in advance

        $root = $_SERVER['DOCUMENT_ROOT'];

        // Check for project
        $check_sql = "SELECT projectref, companyid_FK"
        . " FROM projects"
        . " WHERE projectid = '" . [projectid] . "'";
        sc_lookup(rs2, $check_sql);

        $projectref = {rs2[0][0]};
        $companyid = {rs2[0][1]};

        // Check for company
        $check_sql = "SELECT ref"
        . " FROM company"
        . " WHERE companyid = '" . $companyid . "'";
        sc_lookup(rs1, $check_sql);

        $companyref = {rs1[0][0]};


        // List Directory Contents

        $date = date('Y-m-d');
        $url = "$root/_lib/file/doc/"; // URL to files
        $path = "$url$companyref/$projectref/"; // full path to the folder
        // you must add slash (/) at the end

        // open this directory
        $myDirectory = opendir($path) or die("Unable to open $path");

        // get each entry
        while($entryName = readdir($myDirectory)) {
        $dirArray[] = $entryName;
        }

        // close directory
        closedir($myDirectory);

        //setup zip file of files
        $tmpfolder = "$root/_lib//tmp/";
        $zipname = "$date$companyref$projectref.zip";
        $ziplocation = "$tmpfolder$zipname";

        sc_zip_file($dirArray, $ziplocation);


        // count elements in array
        $indexCount = count($dirArray);
        Print ("$indexCount files<br>\n");

        // sort 'em
        sort($dirArray);

        // print 'em
        print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
        print("<TR><TH>Files Compressed</TH></TR>\n");
        print("<TR><TD><a href=\"$ziplocation\">$zipname</a></td>");
        // loop through the array of files and print them all
        for($index=0; $index < $indexCount; $index++) {
        if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
        print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
        print("</TR>\n");
        }
        }
        print("</TABLE>\n");

        Comment


        • #5
          Hey
          So have managed to get so far now, have added a button to close thankfully found the way of doing so and partialy have the zip working, how ever for some reason it zips the entire platform and not the files contained within the folder....
          Test on lab was working nicely except for the files not being zipped correctly and on the live it times out, I guess because it is zipping the entire 400mb platform......

          Any ideas on how to solve this and only zip the files within the selected folder?

          ?>

          <script>

          function CloseModal()
          {
          window.parent.tb_remove();
          }
          </script>

          <center><input type = "button" name = "btn_return" value = "Close Window" onClick = 'Javascript:CloseModal();'></center>

          <?php

          $root = $_SERVER['DOCUMENT_ROOT'];

          // Check for project
          $check_sql = "SELECT projectref, companyid_FK"
          . " FROM projects"
          . " WHERE projectid = '" . [projectid] . "'";
          sc_lookup(rs2, $check_sql);

          $projectref = {rs2[0][0]};
          $companyid = {rs2[0][1]};


          // Check for company
          $check_sql = "SELECT ref"
          . " FROM company"
          . " WHERE companyid = '" . $companyid . "'";
          sc_lookup(rs1, $check_sql);

          $companyref = {rs1[0][0]};

          // List Directory Contents
          $url = "$root/_lib/file/doc/"; // URL to files
          $path = "$url$companyref/$projectref/"; // full path to the folder

          // open this directory
          $myDirectory = opendir($path) or die("Unable to open $path");

          // get each entry
          while($entryName = readdir($myDirectory)) {
          $dirArray[] = $entryName;
          }

          // close directory
          closedir($myDirectory);

          // count elements in array
          $indexCount = count($dirArray);

          // sort 'em
          sort($dirArray);

          //setup zip file of files
          $date = date('Y-m-d');
          $zipname = "$companyref$projectref-$folder-$date.zip";
          $ziplocation = "$path$zipname";

          sc_zip_file($dirArray, $ziplocation);

          // print 'em
          print("<h4>Project Files - Worked and Quality</h4>");
          print("<TABLE style='width: 100%' border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
          print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th><th>Modified</th><th></th></TR>\n");
          // loop through the array of files and print them all
          for($index=0; $index < $indexCount; $index++) {
          if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files

          $fileDate = filemtime($dirArray[$index]);
          if ($fileDate) {
          $fileDate = date("$format",$fileDate);
          }

          print("<TR><TD>$dirArray[$index]</td>");
          print("<td>");
          print(filetype($dirArray[$index]));
          print("</td>");
          print("<td>");
          print(filesize($dirArray[$index]));
          print("</td>");
          print("<td>");
          print("$fileDate");
          print("</td>");
          print("<td>");
          print("<a href=\"$path$dirArray[$index]\" target=\"_blank\"><img src=\"$root/_lib/img/sys__NM__nm_smallicons_bluehover_bdownload.gif\" alt=\"Download\"/></a>");
          print("</td>");
          print("</TR>\n");
          }
          }
          print("</TABLE>\n");
          print("Download Zip: <a href=\"$ziplocation\" target=\"_blank\">$zipname</a><br/>");
          Print ("$indexCount files - including hidden<br>\n");

          Comment

          Working...
          X