通过FTP添加新文件时运行PHP脚本 [英] Run PHP script when a new file is added via FTP

查看:82
本文介绍了通过FTP添加新文件时运行PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多台相机以随机间隔通过FTP将图像发送到预定文件夹。



例如:
recordings / camera1 / images / - 第一台摄像机
recordings / camera2 / images / - 第二台摄像机


每个人以.jpg格式保存图像,然后关闭FTP连接。



每次添加新文件后,我都需要调用PHP脚本。比方说,无论何时将新映像添加到/ recordings文件夹,我都需要用

  newimage.php?位置调用php脚本= recordings / camera1 / images / picture002.jpg 

等等。



服务器是运行ProFTPD的Linux服务器



我怎样才能完成这项工作?

请注意:Cron作业不是一个选项,因为会有数千个文件,而且我们没有使用数据库。所以我们无法确定是否有任何新文件。

解决方案

我会建议你看一看 mod_exec ProFTPD。
下面是一段解释其目标的引用:

lockquote
mod_exec模块可用于
执行外部程序或脚本
处理
处理FTP命令的过程中的各个点。通过有意识的
设计,ProFTPD不会并且不会
执行外部程序。这是一个
的安全决定,因为它决定
不允许ProFTPD作为一个
的方式来损害一个系统或者
透过外部
中的错误泄露信息程序或脚本。使用
这个模块可以执行这样的外部
程序,并且
也可以通过这些程序将服务器打开到所提到的
可能性的折中或
泄露。

您也可以看看 inotify ,它可以让你监视系统文件活动。


I have multiple cameras sending images at random intervals via FTP to a predetermined folders.

For example:
recordings/camera1/images/ - for first camera
recordings/camera2/images/ - for second camera
etc

Each of them save images in .jpg format and then close FTP connection.

I need to call a PHP script after each time a new file is added. Let's say whenever a new image is added into the /recordings folder I need to call the php script with

newimage.php?location=recordings/camera1/images/picture002.jpg

and so on.

The server is a Linux box running ProFTPD

How I can get this done?

Please note: Cron job is not an option as there will thousands of files and we are not using a DB. So we cannot find out if there are any new files.

解决方案

I would advise you to take a look at the mod_exec of ProFTPD. Here is a quote explaining its goal:

The mod_exec module can be used to execute external programs or scripts at various points in the process of handling FTP commands. By conscious design, ProFTPD does not and will not execute external programs. This is a security decision, as it was decided not to allow ProFTPD to serve as a means of compromising a system or disclosing information via bugs in external programs or scripts. Use of this module allows for such external programs to be executed, and also opens up the server to the mentioned possibilities of compromise or disclosure via those programs.

You can also take a look at inotify which offers you to monitor system file activity.

这篇关于通过FTP添加新文件时运行PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆