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
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    what's wrong with file uploading

    hi all,

    can anyone tell me what's worng with this code?

    PHP Code:
        <?php

    include 'config.inc';
    $id $_GET['id'];

    $wynik mysql_query($zapytanie);

    // Get all the data from the "example" table
    $result mysql_query("SELECT * FROM pracownicy WHERE pracownik_id=$id") or die(mysql_error());

    // keeps getting the next row until there are no more to get
    while($row mysql_fetch_array$result )) {
        
    // Print out the contents of each row into a table
        
    echo $row['imie'];
        echo 
    $row['drugie_imie'];
        echo 
    $row['nazwisko'];
            
    $skan_orzeczenie $row['orzeczenie_skan'];
            
    $dowod_osobisty $row['dowod_osobisty'];
            
    $paszport_pl $row['paszport_pl'];
            
    $paszport_inny $row['paszport_inny'];
            echo 
    '<br /><br /><br />';
    }



    if ((
    $skan_orzeczenie != NULL ) or ($dowod_osobisty != NULL ) or ($paszport_pl != NULL ) or ($paszport_inny != NULL )){
        echo 
    "sa skany<br />";
         if (
    $paszport_pl != NULL ){echo 'paszport pl<br />'; };
    }
    ?>

    <?
    if (!isset($_REQUEST["submit"])) {
    ?>

       <br /><br /><br /> Typ skanu ktory chcesz załadować: <br />
        <form method="POST" action="scan_manager.php?id=<? echo $id ?>" enctype="multipart/form-data">
        <select id="typ_skanu">
        <? if ($dowod_osobisty == NULL ){echo '<option value="28">Dowód osobisty</option>'; }; ?>
        <? if ($paszport_pl == NULL ){echo '<option value="29">Paszport PL</option>';}; ?>
        <? if ($paszport_inny == NULL ){echo '<option value="30">Paszport inny</option>';}; ?>
        </select>
            <br />
     Wybierz plik <input type="file" name="skan">
     <input type="hidden" name="id" value="<? echo $id?>">
            <input type="submit" name="submit" value="wgraj">
        </form>
    <?
    //-- save image to db --
    } else {

     
    $hndl=fopen($_REQUEST["skan"],"r");
      
    $isize=sizeof($_REQUEST["skan"]);

      
    $imgdata="";
      while(!
    feof($hndl)){
        
    $imgdata.=fread($hndl,$isize);
      };

      
    $imgdata=addslashes($imgdata);

      
    $dbconn = @mysql_connect($dbserver,$dbuser,$dbpass) or exit("SERVER Unavailable");
      @
    mysql_select_db($dbname,$conn) or exit("DB Unavailable");

      
    $sql "INSERT INTO skany VALUES (NULL,'"$_REQUEST["typ_skanu"] ."','"$imgdata ."')";
      
    //$sql_upd_pracownik = "INSERT INTO pracownicy"
      //$sql_upd_pracownik = "UPDATE"
      
    @mysql_query($sql,$conn) or exit("QUERY FAILED!");

      
    //mysql_close($conn);

      
    fclose($hndl);

      echo 
    $_REQUEST["typ_skanu"];
    };
    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    $hndl=fopen($_REQUEST["skan"],"r");
    $isize=sizeof($_REQUEST["skan"]);

    $imgdata="";
    while(!feof($hndl)){
    $imgdata.=fread($hndl,$isize);
    };

    $imgdata=addslashes($imgdata);
    Are you storing the image into the DB? It'd be very easy and wise if you save you image inside a directory using move_uploaded_file() and store the path to image in DB.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for quick reply.

    i would like to store it to filesystem, but i have to store as blob. this is because i have to base my code/application on existing db, so i have to follow another application structure.

    do you have any ideas what is wrong?

    i forgot to post config.inc
    PHP Code:
    <?
    $dbhost 
    'localhost';
    $dbuser 'root';
    $dbpass 'admin';
    $dbname 'inplus';

    $conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to mysql');
    mysql_select_db($dbname,$conn) or die(mysql_error());
    ?>

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    do you have any ideas what is wrong?
    Try removing all the error suppression operators (@) from your code.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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