Current time: 12-08-2021, 09:59 PM Hello There, Guest! (LoginRegister)


Post Reply 
Blop data type
Author Message
bodsink Offline
Newbie
*

Posts: 8
Joined: Apr 2009
Reputation: 0
Post: #1
Blop data type
I tried to use blop data type for storing files in mysql, after I upload some files with this metode, I see no hdd space additions.

anyone ever experienced this?

I'm use:
ispCP 1.0.0 OMEGA
build: 20090225
Codename: Priamos


Thanks
Bodsink
12-22-2009 09:19 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #2
RE: Blop data type
This is an example how to store an image in the sql database:
http://www.phpbuilder.com/columns/florian19991014.php3

How big are the files?
If you upload some files with some kb you will see nothing!
Thats normal..
12-22-2009 09:34 PM
Find all posts by this user Quote this message in a reply
bodsink Offline
Newbie
*

Posts: 8
Joined: Apr 2009
Reputation: 0
Post: #3
RE: Blop data type
(12-22-2009 09:34 PM)TheCry Wrote:  This is an example how to store an image in the sql database:
http://www.phpbuilder.com/columns/florian19991014.php3

How big are the files?
If you upload some files with some kb you will see nothing!
Thats normal..

I see one of my users in ispcp, the panel ispcp disk usage warning
You are exceeding the limit of your disk!, But users can still upload a file
like the image that I attach below:


Attached File(s) Thumbnail(s)
       
12-22-2009 10:42 PM
Find all posts by this user Quote this message in a reply
TheCry Away
Member
***

Posts: 851
Joined: Oct 2008
Reputation: 21
Post: #4
RE: Blop data type
Mhhhh... I don't know wheter the mysql-table is included in the caculation ob the disk size.
Btw... Your user does only have 1MB diskspace?
Is this only a test or is this the right adjustment?
12-22-2009 11:10 PM
Find all posts by this user Quote this message in a reply
bodsink Offline
Newbie
*

Posts: 8
Joined: Apr 2009
Reputation: 0
Post: #5
RE: Blop data type
This mysql table

PHP Code:
CREATE TABLE `upload` (`idint(11NOT NULL 
auto_increment
,`namevarchar(30collate latin1_general_ci default 
NULL,`typevarchar(30collate latin1_general_ci default 
NULL, `sizeint(11) default NULL, `dateuploaddate default
NULL,`contentlongblob,`keterangantext collate latin1_general_ci,
PRIMARY KEY  (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci 

and this script php

PHP Code:
<?
    mysql_connect('localhost','userdb','passw');
    mysql_select_db('db_name');

    if($_POST['upload'])
    {
        $tanggal = date("Y-m-d");
         // membaca keterangan
        $ket = $_POST['ket'];
         
        // membaca nama file
        $fileName = $_FILES['userfile']['name'];     
         
        // membaca nama file temporary
        $tmpName  = $_FILES['userfile']['tmp_name']; 
         
        // membaca size file
        $fileSize = $_FILES['userfile']['size'];
         
        // membaca tipe file
        $fileType = $_FILES['userfile']['type'];
         
        // membaca isi file yang diupload 
        $fp  = fopen($tmpName, 'r');
        $content = fread($fp, filesize($tmpName));
        $content = addslashes($content);
        fclose($fp);
         
        // query SQL untuk menyimpan isi file dan informasi lainnya ke database
         
        $query = "INSERT INTO upload (name, size, type, content, dateupload, keterangan) 
                  VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$tanggal', '$ket')";
         
        $hasil = mysql_query($query);
         
        // konfirmasi proses upload
        if ($hasil)  echo "<p>File ".$fileName." telah terupload</p>";
        else echo "<p>File ".$fileName." gagal diupload</p>";

    }
    
    if($_GET['stat']=="download")
    {
        $id      = $_GET['id'];
 
        // query untuk membaca data file berdasarkan ID
        $query   = "SELECT * FROM upload WHERE id = $id";
         
        $hasil   = mysql_query($query);
        $data   = mysql_fetch_array($hasil);
         
        // mengenerate proses download file 
        header("Content-Disposition: attachment; filename=".$data['name']);
        header("Content-length: ".$data['size']);
        header("Content-type: ".$data['type']);
         
        echo $data['content'];

    }
?>
<h1>Upload File</h1>
<form method="post" enctype="multipart/form-data" action="./">
   Pilih File <br>
   <input name="userfile" type="file"><br>
   Keterangan:<br>
   <textarea name="keterangan"></textarea><br>
   <input name="upload" type="submit" value="Upload">
</form>

<?php
echo "<h2>Daftar File Upload</h2>"
 
// query untuk membaca semua file yang terupload
$query "SELECT * FROM upload";
$hasil mysql_query($query);
 
// menampilkan daftar file
echo "<table border='1'>";
echo 
"<tr><th>ID</th><th>Nama File</th><th>Tanggal Upload</th><th>Keterangan</th><th>Action</th></tr>";
while (
$data mysql_fetch_array($hasil))
{
    echo 
"<tr><td>".$data['id']."</td><td><a href='./?stat=download&id=".$data['id']."'>".$data['name']."</a></td><td>".$data['dateupload']."</td><td>".$data['ket']."</td></tr>";

echo 
"</table>";
 
?>

yes, we are conducting testing for users
sorry this script description language indonesia

Regards
Bodsink
12-22-2009 11:49 PM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #6
RE: Blop data type
We've had some discussions regarding soft vs hard quotas (use the search function). Anyway, currently ispcp uses only soft quotas, meaning that:

- Disk usage is updated daily (every night, but you can change it in /etc/cron.d/ispcp).
- Once the user has exceeded it's disk usage, FTP file uploading is diabled.
- All other file creation/uploading methods keep working (web uploads, mysql inserts, etc.).

So yes, the behaviour you are seeing is the expected one in ispcp.
12-23-2009 12:29 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)