PHP Classes

File: testBFILEWPDO.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   Handle Binary Files With PDO   testBFILEWPDO.php   Download  
File: testBFILEWPDO.php
Role: Example script
Content type: text/plain
Description: example script
Class: Handle Binary Files With PDO
Save and load binary files in databases using PDO
Author: By
Last change:
Date: 6 years ago
Size: 1,479 bytes
 

Contents

Class file image Download
<?php
   
require_once('config.php');
   
ini_set("max_execution_time",9999);
   
// ini_set('upload_max_filesize','1024M');
    // ini_set('post_max_size','1024M');

   
require_once('BFile_WithPDO.php');
       
?>
<!doctype html>
<html>
    <head>
        <title>Test for PHP BFile_WithPDO</title>
    </head>
    <body>
            <h1 align="center">Test for PHP BFile_WithPDO</h1>
            <hr>
            <?php
           
echo'<pre>';
            echo
'<h2>Uploaded file</h2>';
            if( isset(
$_POST ) && $_SERVER['REQUEST_METHOD'] == 'POST' ) {
               
BFile_WithPDO::add($bdd,$x=$_FILES[ 'file' ]['name']);
            }
           
?>

            <form Action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
                <input type="file" name="file">
                <input type="submit" value="Submit">
            </form>
           
            <?php
           
if(isset($_FILES['file']['type'])){
                echo
'<h2>reading '.$_FILES[ 'file']['name'].'</h2>';
                if(
substr($_FILES['file']['type'],0,6)=='audio/'){
                   
?> <audio src="file.php?id=<?php echo $x;?>" controls="controls">upgrade your browser to enjoy this</audio>
                    <?php
               
}elseif(substr($_FILES['file']['type'],0,9)=='video/mp4'){
                   
?>
<video src="file.php?id=<?php echo $x;?>" controls="controls">upgrade your browser to enjoy this</video>
                    <?php
               
}elseif(substr($_FILES['file']['type'],0,6)=='image/'){
               
?>
<img src="file.php?id=<?php echo $x;?>"/>
                <?php
               
}else{
                    echo
'format non readable';
                }
            }
       
?>
<hr>
    </body>
</html>