是否有一种简单的方法可以通过表单更改此php脚本中 brocken (在我的图像目录中)的所有3个实例?这样,只要我需要创建一个新的.php文件,我只需输入并点击回车! 关于设置脚本和按钮我需要做些什么,请给我一些指示。
<?php
// Image extensions
$image_extensions = array("png","jpg","jpeg","gif");
// Target directory
$dir = 'images/brocken';
if (is_dir($dir)){
if ($dh = opendir($dir)){
$count = 1;
// Read files
while (($file = readdir($dh)) !== false){
if($file != '' && $file != '.' && $file != '..'){
// Thumbnail image path
$thumbnail_path = "images/brocken/thumbnail/".$file;
// Image path
$image_path = "images/brocken/".$file;
$thumbnail_ext = pathinfo($thumbnail_path, PATHINFO_EXTENSION);
$image_ext = pathinfo($image_path, PATHINFO_EXTENSION);
等等
答案 0 :(得分:0)
你的意思是这样吗?
<?php
// Image extensions
$image_extensions = array("png","jpg","jpeg","gif");
// Target directory
$dir = 'images/brocken';
if (is_dir($dir)){
if ($dh = opendir($dir)){
$count = 1;
// Read files
while (($file = readdir($dh)) !== false){
if($file != '' && $file != '.' && $file != '..'){
// Thumbnail image path
$thumbnail_path = "{$dir}/thumbnail/{$file}";
// Image path
$image_path = "{$dir}/{$file}";
$thumbnail_ext = pathinfo($thumbnail_path, PATHINFO_EXTENSION);
$image_ext = pathinfo($image_path, PATHINFO_EXTENSION);
如果仅更改$dir
变量的路径,则更改$thumbnail_path
和$image_path
。