0
votes

I recently upgraded my LAMP to Ubuntu 16.04 with Dropbox v43.4.50 syncing to this folder/home/arya/Dropbox (NAMA).

I have a PHP script that needs to use a specific file within the Dropbox folder. So, I do file_exists('file:///home/arya/Dropbox (NAMA)/CERTIFICATION/PACE/PACE.xls'), but it returns FALSE. The strange thing is that before I upgraded, file_exists() returned TRUE for this file.

So, I tested to see if the Dropbox folder is being detected by file_exists(), via file_exists('file:///home/arya/Dropbox (NAMA))' and, yes, it returns TRUE.

Then, I tested the next sub-directory file_exists('file:///home/arya/Dropbox (NAMA)/CERTIFICATION)' and it returns FALSE.

So, I thought that maybe the permissions were wrong, but they are correct. I am the owner of all the files and I tested file_exists() on other files outside my Dropbox folder and they are detected.

Also, I made sure the spelling of the folders/files are correct (I copied it from the URL bar in Nautilus to be extra sure) and all the files are accessible outside my PHP script.

Also, I the Dropbox folders have completed their syncing. Every once in a while, one of my co-workers will update another file in Dropbox, but the sync only takes a minute and they never edit the file that I am trying to use in this post.

So, I am now thinking that there is a significant difference occurring between the root Dropbox folder (Dropbox (NAMA)) on my computer and the contents of that folder that are synced/syncing (e.g., Dropbox (NAMA)/CERTIFICATIONS).

Any ideas about why file_exists is not detecting Dropbox sub-folders?

UPDATE: Based on comments, I tried /path/to/file instead of file:///path/to/file, so file_exists('/home/arya/Dropbox (NAMA)/CERTIFICATION/PACE/PACE.xls'), and it still returned FALSE.

UPDATE: var_dump(exec("ls -al /home/arya",$Output)); shows that there are 6 files in /home/arya/Dropbox (NAMA), but var_dump(exec("ls -al /home/arya/Dropbox (NAMA)",$Output)); shows nothing...Why?

1
Dropbox doesn't have anything to do with it, the files and dirs it syncs are regular OS files and dirs. (You can disable the daemon to verify this.) You might try using /path/to/file instead of file:///path/to/file, though that technically shouldn't make any difference. - Alex Howansky
@AlexHowansky Thanks, I tried /path/to/file and it didn't make a difference. - Arya

1 Answers

0
votes

I entered sudo chmod -R 775 Dropbox\ \(NAMA\)/ in terminal and re-ran the script and file_exists('file:///home/arya/Dropbox (NAMA)/CERTIFICATION/PACE/PACE.xls') returned TRUE

So, it was a permissions issue. I think that, although the owner of the file and the user of the PHP script were the same (arya), the group that owned the file (arya:arya) was different than the group that ran the PHP script (arya:www-data) AND the file permissions were set to not allow anyone outside the file owner's group to access it.