开发者

mogrify resize file name with bracket

开发者 https://www.devze.com 2023-03-24 13:40 出处:网络
in php it failed when resize file name that include \"(\" bracket. normally I do exec(\"mogrify -resize {$filewidth}x{$fil开发者_运维知识库eheight}! \\\"$file\\\"\");

in php it failed when resize file name that include "(" bracket.

normally I do

exec("mogrify -resize {$filewidth}x{$fil开发者_运维知识库eheight}! \"$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

how to fix it for php by exec() command

note filename must use bracket.

thank you.


Try to use escapeshellcmd and escapeshellarg when using functions that works with the command line.

For example:

<?php
$filewidth = escapeshellcmd($filewidth);
$fileheight = escapeshellcmd($fileheight);
$file = escapeshellcmd($file);

exec("mogrify -resize {$filewidth}x{$fileheight}! \"$file\"");
?>


$file=str_replace(array('(',')'),array('\\(','\\)'),$file);
0

精彩评论

暂无评论...
验证码 换一张
取 消