Posts Tagged ‘PHP’

File upload/download on MySQL database

Well… It is already a well discussed topic. But when I was first trying to find out how to do this, I really got stuck. Actully it took me a lot of time to find out the key code segment for the purpose.

So, here is what I’ve learned:

The table:

Suppose the structure of the MySQL table (say ‘file_table‘) is like this:

It has three fileds:

  • id : the primary key, integer type with auto increment feature.
  • content: the content of file, blob type.
  • type: varchar type, the type of the file (e.g. doc, pdf etc.).

Upload:

I think you can create a HTML form with a input with file type. Its pretty simple. Just use this code to make a input field be able to upload file:

<input id="file_upload" name="file_upload" type="file" />

Now the backend coding. I’m using PHP for this. Read the rest of this entry »

Basic PHP – Part 1

This article is about very basic of PHP coding, creating functions and database connection using PHP. Later posts may contain detail about other features.

Target viewers are assumed as familiar with C/JAVA or other similar programming language. So I didn’t bother to clarify basic syntax.

Writing PHP code:

All your PHP content should be inside <? ?> tags. That is the file format should be:

<?
Your content here.
?>

Most of the functions in PHP are similar to C. So if you can code in C, you can code in PHP. There are simple exceptions as: Read the rest of this entry »

About
Search
Categories