SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy upload and progressbar

    hi all

    I am using a upload program like below for my site

    http://progphp.com/progress.php

    What i am looking for here is two different thing

    1)when I open a file thru browse button , file should be uploaded and shown the message that file has been uploaded. (without using the upload button)

    2)How can i give a link for multiple uploads.so each time a seprate teaxt box should be added to the browser .How it is possible?


    please help me

    Thanks to all

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    JavaScript. You can't do client-side programming with PHP.

  3. #3
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an upload progress bar script:
    http://encodable.com/filechucker/

    Like Dan said: use JavaScript to add more inputs type=file after every upload.
    FOR SALE: 1 set of morals, never used, will sell cheap

  4. #4
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know its a php forum.do u have any idea how can we do in javascript and how can we connect that with php

    Thanks

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2005
    Location
    Aveiro, Portugal
    Posts
    165
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Hi aniltc

    I liked you upload script very much.
    Is it possible to see it's code?

    Thank you.
    Yours truely
    Mário Ramos

  6. #6
    SitePoint Addict aniltc's Avatar
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    399
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up See the code

    Quote Originally Posted by mjpr View Post
    I liked you upload script very much.
    Is it possible to see it's code?

    Thank you.
    sure

    first-----progress.html
    HTML Code:
    <html>
    <head><title>Upload Example</title></head>
    <body>
    
    <script type="text/javascript">
    
    var counter = 0;
    
    function startProgress(){
        document.getElementById("progressouter").style.display="block";
        fire();
    }
    
    function fire(){
       if (counter < 101){
         document.getElementById("progressinner").style.width = counter+"&#37;";
         counter++;
         setTimeout("fire()",100);
       }
    }
    
    
    </script>
    
    
    <div id="progressouter" style="width: 500px; height: 20px; border: 6px solid red; display:none;">
       <div id="progressinner" style="position: relative; height: 20px; background-color: purple; width: 0%; "> </div>
    </div>
    
    <span onclick="startProgress()">Start me up!</span>
    
    </body>
    </html>
    second progress2.php

    PHP Code:
    <?php
    if(isset($_GET['progress_key'])) {
      
    $status apc_fetch('upload_'.$_GET['progress_key']);

      
    print_r($status);

     
    // $status = apc_fetch('uploadtest_'.$_GET['progress_key']);

     // $status['key'] = 'upload_'.$_GET['progress_key'];
     // print_r($status);
    }
    ?>
    third upload.php
    PHP Code:
    <?php
    $id 
    $_GET['id'];

    ?>

    <form enctype="multipart/form-data" id="upload_form" action="target.php"
    method="POST">
    <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key"
    value="<?php echo $id?>"/>
    <input type="file" id="test_file" name="test_file"/><br/>
    <input onclick="window.parent.startProgress(); return true;"
     type="submit" value="Upload!"/>
    </form>
    fourth---target.php

    PHP Code:
    <?php

    if($_SERVER['REQUEST_METHOD']=='POST') {
      
    move_uploaded_file($_FILES["test_file"]["tmp_name"], "c:\\sw\\wamp\\www\\" $_FILES["test_file"]["name"]);
      echo 
    "<p>File uploaded.  Thank you!</p>";
    }
    ?>
    fifth-----progress.php

    PHP Code:
    <?php
       $id 
    uniqid("");
    ?>
    <html>
    <head><title>Upload Example</title></head>
    <body>

    <script src="http://maps.google.com/maps?file=api&v=2&amp;key=YOURKEYHERE"
                type="text/javascript"></script>

    <script type="text/javascript">

    function getProgress(){
      GDownloadUrl("getprogress.php?progress_key=<?php echo($id)?>", 
                   function(percent, responseCode) {
                       document.getElementById("progressinner").style.width = percent+"%";
                       if (percent < 100){
                            setTimeout("getProgress()", 100);
                       }
                   });

    }

    function startProgress(){
        document.getElementById("progressouter").style.display="block";
        setTimeout("getProgress()", 1000);
    }

    </script>

    <iframe id="theframe" name="theframe" src="upload.php?id=<?php echo($id?>" style="border: none; height: 100px; width: 400px;" > </iframe><br/><br/>
    <div id="progress_win"></div>

    <div id="progressouter" style="width: 500px; height: 20px; border: 6px solid red; display:none;">
       <div id="progressinner" style="position: relative; height: 20px; background-color: purple; width: 0%; "> </div>
    </div>

    </body>
    </html>
    last----getprogress.php

    PHP Code:
    <?php
    if(isset($_GET['progress_key'])) {

      
    $status apc_fetch('upload_'.$_GET['progress_key']);
      echo 
    $status['current']/$status['total']*100;

    }
    ?>

  7. #7
    SitePoint Zealot
    Join Date
    Feb 2005
    Location
    Aveiro, Portugal
    Posts
    165
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Thankx...

    But Somethings not working well.

    1st - the uploading layer doesn't apear. Only a red rectangle with a thick border.
    2nd - I changed the script to upload the file to a specific dir, and although the message "File uploaded" apears, the file is no where to be found.

    Any suggestions?
    Yours truely
    Mário Ramos

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2005
    Location
    Aveiro, Portugal
    Posts
    165
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Angry I think I found out whats going wrong...

    If I call the getprocess.php file, and pass a progress_key, it gives me the error:

    Call to undefined function: apc_fetch() in getprogress.php on line 8

    APC = Alternative PHP Cache, right?
    But I can't install new extensions for PHP...
    Seems I'm stuck...
    Yours truely
    Mário Ramos

  9. #9
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do a search on ajax upload scripts..you'll find some answers there..

  10. #10
    SitePoint Addict
    Join Date
    Jan 2005
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you ave looking for something in Ajax.
    there is this php Ajax upload at http://bluga.net/projects/uploadProgressMeter/

    you can use the class for your upload while doing the JavaScript yourself for multiple uploads.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •