本文介绍了用括号将文件名调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在php中,当调整包含("括号的文件名时,失败.
in php it failed when resize file name that include "(" bracket.
我通常会
exec("mogrify -resize {$filewidth}x{$fileheight}! \"$file\"");
但不适用于带括号的文件名
but it don't work with filename with bracket
通过命令行必须像这样进行转义才能工作.
by command line have to escape like this for working.
mogrify -resize 203x126! 53v-slave-only\(2\).png
如何通过exec()
命令将其修复为php
how to fix it for php by exec()
command
注释文件名必须使用括号.
谢谢.
推荐答案
尝试使用 escapeshellcmd 和 escapeshellarg 时,命令行.
Try to use escapeshellcmd and escapeshellarg when using functions that works with the command line.
例如:
<?php
$filewidth = escapeshellcmd($filewidth);
$fileheight = escapeshellcmd($fileheight);
$file = escapeshellcmd($file);
exec("mogrify -resize {$filewidth}x{$fileheight}! \"$file\"");
?>
这篇关于用括号将文件名调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!