Synology NAS PHP file copy issue.

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
JasonHague
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Mar 19, 2018 4:09 pm

Mon Mar 19, 2018 4:34 pm

I'm setting up a Synology NAS (DS418 Play) and one of its functions is photo storage. Users upload their photos to a personal upload folder via Synologys Drive app. Then a PHP script renames the photo and moves it into a sub dir in the photo dir, this is all based on exif data and the users id. The photo dir and sub dirs are indexed and managed by 'PhotoStation', Synology's standard gallery app. It all works well save for one issue... PhotoStation will not index a photo copied into place by the script yet it will immediately index a the same photo if I copy it into place via SMB or FTP. I have tried using copy, rename and shell commands... no joy. I suspect that permissions may lay at the root of the issue and I have used PHP to set the permissions exactly the same as if they where copied from my Linux box. Still no joy! There may be some 'root' or system permission that is not being set but I am ignorant of how that might work.

I'm trying to use FTP via PHP to copy the photos into place but predictably there are issues, scripts running on a Synology box don't seem to be able to utilize the FTP functions while the Synology webserver can BUT for some reason even PHP on the webserver runs into permissions issues using the same user account that can preform the task via an FTP client (Filezilla). Still working on the WHY for that one?!

The simplest alternative is if I work out what why the PHP rename or copy functions are not producing the same result as a drag and drop copy from my workstation.

I'm a mediocre coder... and advice from guru's would be greatly appreciated.

Cheers J

JasonHague
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Mar 19, 2018 4:09 pm

Mon Mar 19, 2018 5:14 pm

I just tried chmod to 0777 and the file shows up in the Synology file browser but is still not indexed by photostation. If I rename it in the file browser it instantly gets indexed by photostation. I think that is about a broad as I can make permissions! Only for debugging purposes of course, don't want to have it that way permanently.

I have asked for help @ the Synology forums but no one seems to know anything.

Cheers
J

JasonHague
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Mar 19, 2018 4:09 pm

Mon Mar 19, 2018 6:32 pm

OK...

I have PHP using FTP to upload a file and it is being indexed quickly.

So its a fix...

Kind of... the script runs well under the web server BUT PHP running as a script called from a shell command doesn't have access to the FTP functions.

I'm trying to get it to use the same PHP ini file that the server uses but all sorts of errors are cropping up.

Task: Photo Import
Start time: Tue, 20 Mar 2018 13:25:47 GMT
Stop time: Tue, 20 Mar 2018 13:25:47 GMT
Current status: 255
Standard output/error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php70/modules/syno_compiler.so' - /usr/local/lib/php70/modules/syno_compiler.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Uncaught Error: Call to undefined function ftp_connect() in /volume1/scripts/photo_import/import.php:666
Stack trace:
#0 /volume1/scripts/photo_import/import.php(257): file_transfer('192.168.1.9', 'PHPUser', 'x{DY2.', '/volume1/homes/...', '/photo/2018/03/...', 'Image')
#1 /volume1/scripts/photo_import/import.php(50): import('photo', '/volume1/photo/...', '/volume1/homes/...', '/volume1/homes/...', '/volume1/homes/...', true, true, true, Array, '192.168.1.9', '/photo', 'PHPUser', 'x{DY2.')
#2 {main}
thrown in /volume1/scripts/photo_import/import.php on line 666

Fatal error: Uncaught Error: Call to undefined function ftp_connect() in /volume1/scripts/photo_import/import.php:666
Stack trace:
#0 /volume1/scripts/photo_import/import.php(257): file_transfer('192.168.1.9', 'PHPUser', 'x{DY2.', '/volume1/homes/...', '/photo/2018/03/...', 'Image')
#1 /volume1/scripts/photo_import/import.php(50): import('photo', '/volume1/photo/...', '/volume1/homes/...', '/volume1/homes/...', '/volume1/homes/...', true, true, true, Array, '192.168.1.9', '/photo', 'PHPUser', 'x{DY2.')
#2 {main}
thrown in /volume1/scripts/photo_import/import.php on line 666

JasonHague
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Mar 19, 2018 4:09 pm

Mon Mar 19, 2018 10:43 pm

OK... I have the FTP working from the script BUT I really still want to know why the rename and copy functions are not triggering the indexing!

Post Reply