Skip to content

Posts from the ‘PHP’ Category


Converting HTML document with IMG src link to IMG embedded data in PHP

In my previous blog, I need to convert a HTML document with IMG src link to IMG with embedded base64 image content. Here is a PHP script that scans the HTML document and replace the IMG tags with embedded content, i.e. changing from this

<img src='./4/data.png'/>

to that

<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhE....

Read more »


Passing Javascript objects in ExtJS Store’s params and becomes PHP associative array on the server side

Suppose you need to pass a Javascript object as a parameter in ExtJS Store to PHP server side and you want to automatically convert into PHP associative array. You can simply do something like this inside the Store’s config:

baseParams: {
  "argArr[0][field1]": argArr[0].field1,
  "argArr[0][field2]": argArr[0].field2,

Read more »


How to send & receive serialized simple objects across PHP & Python? Of course! JSON

I hacked a client & server PHP programs for part of a demo. However, the notorious memory intensive PHP makes my server process swallowing so much memory (the size of sample data and lots of associative arrays) to a point that is impractical to run. So I decided to bite the bullet to port the server side into Python. Then it was fine until it hit me, “How is the PHP client going to talk to Python server side?” Read more »


An enhanced version of

The StoreMenu is a dynamic menu using ExtJS Store class to retrieve and expand the menu items from the server side. It is a very useful utility class. For usage and technical detail, you can refer to the forum. However, there are a number of areas I think it can be improved which are

  1. menu item’s handler function should not necessary return from the server side.
  2. since it is extended from which should be also capable of adding buttons as well as loading & add menu items from the Store.
  3. related to no.2, if the StoreMenu handles both menu buttons & dynamic menu items, the users should be able to assign where (offset) dynamic items to expand in respective to the static items.
  4. Dis/Enable to load from Store every time when the menu is expanded.

Read more »


Extending ExtJS CRUD operations on id and baseParams

There are couple things I would like to extend the ExtJS CRUD operations for my application.

  1. If the baseParams property is specified inside a Store object, the HttpProxy will pass the content of baseParams as part of the JSON string. However, the server side Php’s CRUD operations ignores it, ie none of the data in baseParams can be found in Request->$params
  2. The syntax for id field in Restful URL is too restricted for only [0-9]+

Read more »


Force downloading XML files on IE

I have this old code for downloading files using hidden IFRAME. Strangely, it just doesn’t work on IE when downloading XML files, it works on anything other than .xml file extension. Making the hidden IFRAME visible shows that IE automatically opens the XML file within the IFRAME, even the HTTP MIME header is ‘application/force-download’ (I have also tried ‘download, x-download’) on the server side. Read more »


How to use Ext JS CRUD PHP example

Ext JS CRUD enables Store object to perform create, read, update, destroy through a common interface in MVC style. In the example, Sencha provides a demo example of CRUD operations. In here, I describe how the backend PHP sides work along with CRUD. Read more »


Posting JSON data from Ext JS to PHP

I have got a Ext-JS web application which needs to send a group of object data to the PHP server side, then processes and stores them. However, it is easier and less effort to pack the Javascript objects in JSON and POST to the server side. Then on PHP side decodes the receiving JSON string and extracts necessary data and stores them. It took me a while to analyse and debug what the problem was and here is how to do it. Read more »


Note on implementing Ajax style hidden IFRAME upload page on FreeBSD 8.0

This problem has taken me a while to track it down. The same code works fine on Ubuntu with IE8, Firefox, Safari but it just doesn’t work on FreeBSD. Read more »


Quick steps on setting up Apache + SSL + PHP + JSON on FreeBSD 8.0

There are many webpages that offer comprehensive information on setting up Apache on FreeBSD, such as However, I can’t find any tutorial just list the quick steps to get me going in minutes. So here is one. Read more »