PHP read from a mounted drive

Recently, I needed to read from a mounted drive on osx using Apache and PHP. I need to grab some file names in a certain directory using opendir or scandir, then dynamically populate a select dropdown box.

The issue is, the default apache user is _www being in the _www group, while the mounted drive allows only the “staff” group to enter.

In my case, I cannot change the mounted drive access permissions.

So, what options are left? I guess I can only change the apache user. If you decide to take this path, there are two options. One is to add the “staff” group to your default _www user. Read the man page yourself… The other option is to assign an existing user (who has access to the mounted drive) to apache. I picked the latter, don’t ask me why… ok, coz I am lazy…

Open up your /etc/apache2/httpd.conf , you will need to sudo.

Find the line that has “User _www”. Change that to say “User john_smith”. Then change the next line to the right group. If you don’t know what user and group to use here, just do an “ls -ld /Volumes/mounted_drive/” and use the user and group there.

Save it. Then restart apache by issuing “sudo apachectl restart”.

That should do it.

dataTables editable plugin multiple select

If you are using the jQuery datatable with the editable extension, you probably know that you can only highlight one single row (tr). In my opinion, that’s really for the purpose of integrating the single row add/delete functions.

If you need to implement multiple row operations, thus needing multiple row selection, here is how you can do it:

  1. Open up jquery.dataTables.editable.js
  2. Toward the end of the file, look for

    $(oTable.fnSettings().aoData).each(function () {

  3. Comment that out.

Obviously by doing this we are breaking the single row add/del feature. So, you will need to make sure you are not using the builtin add/del buttons, namely btnAddNewRow and btnDeleteRow.

Now, how to grab the highlighted rows? If you follow the user manual, each of your tr should have an ID.

$('#myTable_id .row_selected').each(function () {
	item_id =;
	// then do something with this id

Whatever you do, consider refreshing your table or the whole page to reflect the latest table content.