exec() button problem

Discussion in 'PHP' started by neox182, Aug 8, 2010.

  1. #1
    Hello

    I installed MediaInfo in my server (http://mediainfo.sourceforge.net/) and I'm creating a PHP script for executing it. But I'm stuck at the action button.

    The button doesn't work, it does anything. I think it is for a naming problem.

    Here's the code:

    <?php
    if ($handle = opendir('files')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
              echo "$file<br/>";
    		}
        }
        closedir($handle);
    }
    if (isset($_POST["cap"])) {
    exec("mediainfo --output=html --logfile=/var/www/html/files/hello.html /var/www/html/files/*.mp4");
    echo "<h5>Done.-</h5>";
    			}
    echo ('<input  type="submit" style="font-size:16px; font-weight:bold; cursor:pointer;" select name="cap"  value="Capture"/></div></div>');
    ?>
    PHP:
    Any help will be grateful.

    Thanks

    neox182
     
    neox182, Aug 8, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    I'm not familiar with the program but I can see your button needs <form> tags so try this:
    echo ('<form action="#" method="post"><input  type="submit" style="font-size:16px; font-weight:bold; cursor:pointer;" select name="cap"  value="Capture"/></form></div></div>');
    
    
    PHP:
     
    MyVodaFone, Aug 8, 2010 IP
  3. swashata

    swashata Member

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I guess you need to set the proper path there inside the exec!

    Do one thing, make a file with name dirname.php and put the following code inside
    
    <?php
    echo dirname(__FILE__);
    ?>
    
    PHP:
    Now place that file inside the same folder where the script having the code mentioned by you, or hello.html resides! Now run the dirname.php from your browser and note the output! It might be something like
    [B]/home/yourdoma/public_html/yoursite/bla[/B]
    Code (markup):
    Now note this path info from the exec... [The bolded part]
    exec("mediainfo --output=html --logfile=[B]/var/www/html/files/[/B]hello.html [B]/var/www/html/files[/B]/*.mp4");
    Code (markup):
    Replace those parts with the output you got before!

    I am not sure about this, but this is worth a try!
     
    swashata, Aug 8, 2010 IP
  4. neox182

    neox182 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you a lot, that was the trick! +rep
     
    neox182, Aug 8, 2010 IP