小编Ary*_*rya的帖子

如何在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");}
Run Code Online (Sandbox Code Playgroud)

PHP脚本适用于网络扫描程序,但不适用于USB扫描程序.
如果我选择任一USB扫描仪(当前为MFC-9840CDW)并运行脚本,则文件/var/log/apache2/error.log显示:

scanimage: open of device brother3:bus6;dev1 failed: …
Run Code Online (Sandbox Code Playgroud)

php linux scanning

10
推荐指数
1
解决办法
1919
查看次数

在 PhpSpreadsheet 中读取 Xlsx 文件

我想读取xlsx在 Microsoft Excel 中创建的文件,但是当我运行以下代码时...

$Source_File = "test.xlsx";
$Spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($Source_File);
Run Code Online (Sandbox Code Playgroud)

...我收到以下错误:

Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Unable to identify a reader for this file in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php:163
Stack trace:
  #0 /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php(93): PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile('file:///home/ar...')
  #1 /var/www/html/Function_Spreadsheet.php(480): PhpOffice\PhpSpreadsheet\IOFactory::load('file:///home/ar...')
  #2 /var/www/html/Function_Home.php(3747): Spreadsheet_Reader_1('/var/www/html/F...', 3745, Array, Array)
  #3 {main} thrown in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php on line 163
Run Code Online (Sandbox Code Playgroud)

如果我改为使用,我会得到同样的错误 $Spreadsheet = IOFactory::load($Source_File);

如果我改为使用,我会收到以下错误 $Spreadsheet = $reader->load($Source_File);

Warning: ZipArchive::getFromName(): Invalid or uninitialized Zip object in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 311

Warning: ZipArchive::getFromName(): Invalid or uninitialized Zip object in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line …
Run Code Online (Sandbox Code Playgroud)

php excel xlsx ziparchive phpspreadsheet

10
推荐指数
1
解决办法
2万
查看次数

udev - += 和 := 之间的区别

我试图了解udev运算符,以便为我的设备创建规则,但关于运算符的几个在线资源之间似乎存在差异,从而阻止了以后对密钥的更改。哪个udev操作员(如果有的话)将阻止以后对密钥进行更改?

以下两个关于 udev 运算符的来源之间似乎存在差异,这会阻止以后对密钥进行更改。

http://www.reactivated.net/writing_udev_rules.html指出+: ensures that no later rule can have any effect,但man udev指出:=将会Assign a value to a key finally; disallow any later changes.man udev还表示"+="将会Add the value to a key that holds a list of entries.。那么,哪个udev操作员(如果有的话)将阻止以后对密钥进行更改?

我通过为我的 USB 闪存驱动器创建 /etc/udev/rules.d/80-test.rules 来测试这个问题。该规则具有以下键值行...

SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/bin/device_added.sh" 
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/bin/device_added_2.sh"
Run Code Online (Sandbox Code Playgroud)

可执行文件device_added.sh包含...

`echo "USB device removed  at $(date)" …
Run Code Online (Sandbox Code Playgroud)

linux udev

5
推荐指数
1
解决办法
1226
查看次数

XPath 除法运算符

正斜杠是/XPath 表达式中的有效除法运算符吗?在书的第 132 页Pro PHP XML and Web Services(ISBN-13:9781590596333),在表 4-3(XPath 运算符)中,仅div列出了除法运算符,但在第 146 页上,有一个使用的示例/获取舍入平均值某些元素中数字的价格:round(sum(//*[local-name()="price"]) / count(//*[local-name()="price]))

在该示例中,似乎/前一个count被用作除法运算符。

xml xpath

4
推荐指数
1
解决办法
3008
查看次数

Perl的printf宽度修饰符在map运算符中不起作用

为什么,当我做map{printf "%4s\n",File::Spec->rel2abs($_)}glob '*';print map{sprintf "%4s\n",File::Spec->rel2abs($_)}glob '*';4个空格字符输出到字符串的左边?...

/var/www/html/Physics/Electronics/file1.txt
/var/www/html/Physics/Electronics/file2.txt
/var/www/html/Physics/Electronics/file3.txt
/var/www/html/Physics/Electronics/file4.txt
Run Code Online (Sandbox Code Playgroud)

似乎我必须做map{print "\x{20}\x{20}\x{20}\x{20}",File::Spec->rel2abs($_),"\n"}glob '*';的是输出字符串左边的4个空格字符...

    /var/www/html/Physics/Electronics/file1.txt
    /var/www/html/Physics/Electronics/file2.txt
    /var/www/html/Physics/Electronics/file3.txt
    /var/www/html/Physics/Electronics/file4.txt
Run Code Online (Sandbox Code Playgroud)

perl printf

0
推荐指数
1
解决办法
40
查看次数

标签 统计

linux ×2

php ×2

excel ×1

perl ×1

phpspreadsheet ×1

printf ×1

scanning ×1

udev ×1

xlsx ×1

xml ×1

xpath ×1

ziparchive ×1