Ankündigung

Einklappen
Keine Ankündigung bisher.

Apc_fetch

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Apc_fetch

    Hallo,

    ich baue gerade ein Script zum Thema Ladebalken mit PHP und Ajax.
    Der Ladebalken läuft schon mal.
    Doch ich hätte gerne noch die Infos, wie viele Daten bereits
    geladen wurden und wie die Daten hießt.
    Ich komme im Augenblick nicht weiter?
    Ich kann doch alle Daten mit apc_fetch auslesen, oder?
    Hier das Srcipt aus uploadframe.php
    PHP-Code:
    <?php

    $url 
    basename($_SERVER['SCRIPT_FILENAME']);

    //Get file upload progress information.
    if(isset($_GET['progress_key'])) {
        
    $status apc_fetch('upload_'.$_GET['progress_key']);
      echo 
    $status['current']/$status['total']*100;
        die;
    }
    ?>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script>
    <link href="style_progress.css" rel="stylesheet" type="text/css" />

    <script>
    $(document).ready(function() { 
    //

        setInterval(function() 
            {
        $.get("<?php echo $url?>?progress_key=<?php echo $_GET['up_id']; ?>&randval="+ Math.random(), { 
            //get request to the current URL (upload_frame.php) which calls the code at the top of the page.  It checks the file's progress based on the file id "progress_key=" and returns the value with the function below:
        },
            function(data)    //return information back from jQuery's get request
                {
                    $('#progress_container').fadeIn(100);    //fade in progress bar    
                    $('#progress_bar').width(data +"%");    //set width of progress bar based on the $status value (set at the top of this page)
                    $('#progress_completed').html(parseInt(data) +"%");    //display the % completed within the progress bar
                }
            )},500);    //Interval is set at 500 milliseconds (the progress bar will refresh every .5 seconds)

    });


    </script>
    und hier noch ein Teil aus upload.php
    PHP-Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script>

    <!--display bar only if file is chosen-->
    <script>

    $(document).ready(function() { 
    //

    //show the progress bar only if a file field was clicked
        var show_bar = 0;
        $('input[type="file"]').click(function(){
            show_bar = 1;
        });

    //show iframe on form submit
        $("#form1").submit(function(){

            if (show_bar === 1) { 
                $('#upload_frame').show();
                function set () {
                    $('#upload_frame').attr('src','upload_frame.php?up_id=<?php echo $up_id?>');
                }
                setTimeout(set);
            }
        });
    //

    });

    </script>
    Danke schon mal für die Hilfe

  • #2
    mach mal ein var_dump auf $status, dann siehst du was dir zur Verfügung steht
    [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
    | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

    Kommentar


    • #3
      danke,

      aber es stehen sonst keine Infos zur Verfügung.
      Es kommt als nicht weiter, auch der Ladebalken
      ändert dann seine Farbe nicht mehr. Die Prozentzahlen
      zählen aber noch mit.
      Es liegt an diesem Bereich:
      PHP-Code:
      $url basename($_SERVER['SCRIPT_FILENAME']);

      //Get file upload progress information.
      if(isset($_GET['progress_key'])) {
          
      $status apc_fetch('upload_'.$_GET['progress_key']);
        echo 
      $status['current']/$status['total']*100
      Hab aber auch shon mal es mit dem jenson code versucht.
      Das gleiche Problem. Draum melde ich mich ja hier.

      Kommentar


      • #4
        apc-version ?
        [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
        | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

        Kommentar


        • #5
          Php 5.2.14
          apc 3.1.2

          Kommentar


          • #6
            Und was konkret gibt dir das var_dump auf den status aus ?

            Weil das sollte eigentlich alle benötigten felder enthalten:

            http://de3.php.net/manual/en/apc.con...ni.apc.rfc1867
            [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
            | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

            Kommentar


            • #7
              also ich komme das einfach nicht hin.
              entweder bin ich zu alt oder sonst was.

              hab nun alle möglichen variante ausprobiert und nicht läuft.

              Kommentar


              • #8
                Zitat von robo47 Beitrag anzeigen
                Und was konkret gibt dir das var_dump auf den status aus ?
                Denn ohne Input wo konkret dein problem ist kann dir keiner weiterhelfen, die Glaskugel sind leider seit Jahren kaputt.
                [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
                | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

                Kommentar


                • #9
                  das ich schon das var_dump($status) an so vielen stellen eingebaut habe
                  und immer nur "NULL" erhalte.
                  aktuell steht das var_dum so drin:
                  PHP-Code:
                  <?php

                  $url 
                  basename($_SERVER['SCRIPT_FILENAME']);

                  //Get file upload progress information.
                  if(isset($_GET['progress_key'])) {
                      
                  $status apc_fetch('upload_'.$_GET['progress_key']);
                    echo 
                  $status['current']/$status['total']*100;
                  die;
                  }
                  var_dump($status);
                  ?>
                  dann erhalte ich zwar den ladenbalken aber darüber nur "NULL"

                  Kommentar


                  • #10
                    wäre wäre es mal dein var_dump direkt an die stelle zu machen wo du $status belegst und nicht wo ganz anders hin ?

                    Dein $status wird IMMER NULL sein, weil du es IM if erst füllst und im if IMMER die; nutzt, so kommt er nie zu einem var_dump ...
                    [URL="http://www.robo47.net"]robo47.net[/URL] - Blog, Codeschnipsel und mehr
                    | :arrow: [URL="http://www.robo47.net/blog/192-Caching-Libraries-and-Opcode-Caches-in-php-An-Overview"]Caching-Klassen und Opcode Caches in php[/URL] | :arrow: [URL="http://www.robo47.net/components"]Robo47 Components - PHP Library extending Zend Framework[/URL]

                    Kommentar

                    Lädt...
                    X