Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,845
    Thanks
    21
    Thanked 157 Times in 148 Posts

    output control function here?

    Hi,

    I have a HTML form:

    Code:
    <form method="post" enctype="multipart/form-data" action="xxxxxxxxx.php">
    
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
    
    <br>
    <table border="0" cellpadding="0" width="100%">
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[1]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[2]"></td>
    </tr>
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[3]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[4]"></td>
    </tr>
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[5]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[6]"></td>
    </tr>
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[7]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[8]"></td>
    </tr>
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[9]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[10]"></td>
    </tr>
    <tr>
    <td align="right" width="45%"><input type="file" name="upload[11]"></td>
    <td width="10%"></td>
    <td align="left" width="45%"><input type="file" name="upload[12]"></td>
    </tr>
    </table>
    
    <br><br><center><input type="submit" value="Submit"><input type="reset" value="Clear Form"></center>
    <br><br>
    
    
    <input type="hidden" name="mail_to" value="xxxxx@xxxxxxxxxx.com">
    <input type="hidden" name="subject" value="File Transfer Confirmation">
    <input type="hidden" name="receipt" value="xxxxxx.shtml">
    
    
    
    </form>

    that I'm using to upload files to a server...When one or more files are selected and then submitted (to be uploaded), a PHP script/file takes over and handles the upload of the files to the server...

    What i want to do is, for larger files, add a little animated message that says the files are still transferring....So I whipped out ImageReady and made myself an animated .gif.....

    My idea is, when the form is submitted, the user is whisked away to the PHP page that will process the upload...and while that script is transferring the files, I want to force the browser to display my animated .gif with the following code (currently placed at the beginning of the PHP page, before the upload processing code):

    PHP Code:
    if (empty($_FILES['upload']['name'][1]) && empty($_FILES['upload']['name'][2]) && empty($_FILES['upload']['name'][3]) && empty($_FILES['upload']['name'][4]) && empty($_FILES['upload']['name'][5]) && empty($_FILES['upload']['name'][6]) && empty($_FILES['upload']['name'][7]) && empty($_FILES['upload']['name'][8]) && empty($_FILES['upload']['name'][9]) && empty($_FILES['upload']['name'][10]) && empty($_FILES['upload']['name'][11]) && empty($_FILES['upload']['name'][12]))
    {
        
    $v $v;
    }
    else
    {
        print 
    '<br<br><center><img src="transfer_animation.gif"></center>';


    The problem I'm having is that, when the submit button is pressed on the HTML form, the browser never advances to the PHP page and displays my animation....it stays at the HTML form page, the mouse pointer turns to the hour glass, and the status bar of the browser indicates that it's working on something (obviously, it must be uploading, becasue these pages DO work like they're supposed to)....

    The funny thing is that the animation code appears BEFORE the upload processing code on the PHP page...So I just assumed that the animation would output to the browser BEFORE the upload processing code kicked in...

    How do I force the page to advance to my PHP page and display my animated .gif ??....I'm wondering if this could be acheived with a PHP output control function on the PHP page, to keep the upload processing code from kicking in until after the animation is outputted to the browser, but I'm not sure....

    Can someone help?

    Thanks.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Perhaps output control will suffice for what you are looking for?
    ex:
    PHP Code:

    ob_start
    ();
    echo 
    '<img src="yourimage.gif" />'// And whatever else you want to use

    ob_end_flush();

    // Continue with your processing code, perhaps adjust after or provide a message displaying upload completed. 
    Didn't test this or anything of the sorts, and I'm not really the king of output buffering, but this will probably work for you.

  • #3
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,845
    Thanks
    21
    Thanked 157 Times in 148 Posts
    I tried the code that you provided, and it still didn't force the browser to advance to the next page and output the animation....

    I even tried this code:

    PHP Code:
    if (empty($_FILES['upload']['name'][1]) && empty($_FILES['upload']['name'][2]) && empty($_FILES['upload']['name'][3]) && empty($_FILES['upload']['name'][4]) && empty($_FILES['upload']['name'][5]) && empty($_FILES['upload']['name'][6]) && empty($_FILES['upload']['name'][7]) && empty($_FILES['upload']['name'][8]) && empty($_FILES['upload']['name'][9]) && empty($_FILES['upload']['name'][10]) && empty($_FILES['upload']['name'][11]) && empty($_FILES['upload']['name'][12]))
    {
        
    $v $v;
    }
    else
    {
        print 
    '<br><br><center><img src="transfer_animation.gif"></center>';

    }


    print 
    '<br><br><center><img src="transfer_animation.gif"></center>';
    die(); 
    on the off chance that the IF statement was getting skipped over....The result? The same as before!!! Using die() still didn't force the script to exit and output anything to the browser thus far!

    Very strange. Any thoughts?

    Thanks.

    Edit: Maybe I need to apply the output buffer controls to the chunk of code that processes the file uploads, instead? In other words, force that chunk of code to NOT run until everything else in the script has run its course.....How would that work?
    Last edited by chump2877; 07-09-2005 at 04:10 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,845
    Thanks
    21
    Thanked 157 Times in 148 Posts
    Argh, I can't figure this out...it seems that whatever I do, the upload processing code HAS TO go first....It's to the extent that if I insert a die() in the code somewhere, the file upload is processed first BEFORE die() tells the script to end...even if die() is placed BEFORE the upload processing code...

    It's almost like if you call on a $_FILES variable ANYWHERE in the script, this takes precedence over anything else in the code, and must be evaluated first...or something like that

    Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪


  •  

    Posting Permissions

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