php扫描获取内容吗,如何在PHP中扫描

我想从我的

PHP脚本中扫描.我正在使用Ubuntu 14.04 LTS,Brother MFC-7840W扫描仪(位于工作中)和Brother MFC-9840CDW(位于家中).当扫描仪作为网络扫描仪连接到计算机时,我可以从终端和PHP扫描.但是,当扫描仪作为USB扫描仪连接到计算机时,我无法从PHP扫描(我仍然可以从终端扫描).

为什么我的PHP脚本无法访问USB扫描仪,但$USER能够?

我在工作中开始提出这个问题,但现在我在家,所以我将尝试从PHP脚本访问Brother MFC-9840CDW USB扫描仪.

以下是我用于扫描的PHP代码片段:

if($_POST['ScanDevice'] == "brother3:net1;dev0") // if MFC-7840W network scanner

{$scanner = escapeshellarg($_POST['ScanDevice']);}

elseif($_POST['ScanDevice'] == "brother3:bus3;dev1") // if MFC-7840W USB scanner

{$scanner = escapeshellarg($_POST['ScanDevice']);}

elseif($_POST['ScanDevice'] == "brother3:net1;dev1") // if MFC-9840CDW network scanner

{$scanner = escapeshellarg($_POST['ScanDevice']);}

elseif($_POST['ScanDevice'] == "brother3:bus6;dev1") // if MFC-9840CDW USB scanner

{$scanner = escapeshellarg($_POST['ScanDevice']);}

$command = "scanimage -d {$scanner} --resolution {$_POST[ScanResolution]} --mode {$_POST[ScanColor]} > {$filename}";

echo exec($command,$op,$result);

if($result > 0)

{die("ERROR");}

PHP脚本适用于网络扫描程序,但不适用于USB扫描程序.

如果我选择任一USB扫描仪(当前为MFC-9840CDW)并运行脚本,则文件/var/log/apache2/error.log显示:

scanimage: open of device brother3:bus6;dev1 failed: Invalid argument

问题出现了:设备brother3:bus6; dev1是否存在?

以下是scanimage –list-devices在家中终端输入时显示的内容(MFC-9840CDW所在的位置):

[pixma] udp_command: No data received (select): timed out

[pixma] udp_command: No data received (select): timed out

[pixma] udp_command: No data received (select): timed out

[pixma] Cannot read scanner make & model: �+�&

device `brother3:net1;dev1' is a Brother MFC-7840W SCANNER

device `brother3:net1;dev0' is a Brother MFC-9840CDW Scanner-MFC-9840CDW

device `brother3:bus6;dev1' is a Brother MFC-9840CDW USB scanner

为了证明USB扫描器适用于$USER,我在终端中输入以下命令:

scanimage --test -d 'brother3:bus6;dev1'

这表现了:

scanimage: rounded value of br-x from 215.9 to 215.88

scanimage: rounded value of br-y from 355.6 to 355.567

scanimage: scanning image of size 1664x2776 pixels at 24 bits/pixel

scanimage: acquiring RGB frame, 8 bits/sample

scanimage: reading one scanline, 4992 bytes... PASS

scanimage: reading one byte... PASS

scanimage: stepped read, 2 bytes... PASS

scanimage: stepped read, 4 bytes... PASS

为了证明用户www-data无法访问USB扫描器,我在终端中输入以下命令:

sudo -u www-data scanimage --test -d 'brother3:bus6;dev1'

这表现了:

scanimage: open of device brother3:bus6;dev1 failed: Invalid argument

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值